#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;}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBub2RlIHsKCWludCB2YWx1ZTsKCW5vZGUgKiBuZXh0OwoJbm9kZShpbnQgdiwgbm9kZSAqIG4gPSBOVUxMKSB7CgkJdmFsdWUgPSB2OwoJCW5leHQgPSBuOwoJfQp9OwoKc3RydWN0IGNoYWluIHsKCW5vZGUgKiBoZWFkOwoJaW50IGNvdW50OwoJY2hhaW4obm9kZSAqIGggPSBOVUxMKSB7CgkJaGVhZCA9IGg7CgkJY291bnQgPSAwOwoJfQoJfmNoYWluKCkgewoJCWNsZWFyKCk7Cgl9CglpbnQgcHVzaChpbnQgdikgewoJCWhlYWQgPSBuZXcgbm9kZSh2LCBoZWFkKTsKCQkrK2NvdW50OwoJCXJldHVybiB2OwoJfQoJaW50IHBvcCgpIHsKCQlpbnQgdiA9IGhlYWQtPnZhbHVlOwoJCW5vZGUgKiBuID0gaGVhZDsKCQloZWFkID0gaGVhZC0+bmV4dDsKC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