#include <iostream>
#include <string>

using namespace std;

struct node {
	int value;
	node * next;
	node(int v, node * n = NULL) {
		value = v;
		next = n;
	}
};

struct chain {
	node * head;
	int count;
	chain(node * h = NULL) {
		head = h;
		count = 0;
	}
	~chain() {
		clear();
	}
	int push(int v) {
		head = new node(v, head);
		++count;
		return v;
	}
	int pop() {
		int v = head->value;
		node * n = head;
		head = head->next;
		delete n;
		--count;
		return v;
	}
	int back() {
		return head->value;
	}
	void clear() {
		while(head != NULL) pop();
	}
	int size() {
		return count;
	}
	bool empty() {return !count;}
} stack;

int main() {
	string s;
	while (cin >> s) {
		if (s == "exit") {cout << "bye\n"; return 0;}
		if (s == "push") {int x; cin >> x; stack.push(x); cout << "ok\n";}
		if (s == "pop") 
			if (stack.empty()) cout << "error" << endl;
			else cout << stack.pop() << endl;
		if (s == "back") 
			if (stack.empty()) cout << "error" << endl;
			else cout << stack.back() << endl;
		if (s == "clear") {stack.clear(); cout << "ok\n";}
		if (s == "size") {cout << stack.size() << endl;}
	}
}