#include <iostream>
using namespace std;
struct stack {
int size=0;//размер
int storage[1000];//массив
void push (int n)//добавление эл-та
{
storage[size]=n;
size++;
}
int pop () //удаление эл-та
{
int b=storage[size-1];
size--;
return b;
}
};
int main ()
{
stack st;
string s;
while (55)
{
cin >> s;
if (s=="push")
{
int n;
cin >> n;
st.push(n);
cout << "ok\n";
}
if (s=="pop")
{
if (st.size==0)
{
cout << "error\n";
}
else cout << st.pop() << endl;
}
if (s=="exit")
{
cout << "bye\n";
break;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCnN0cnVjdCBzdGFjayB7CiAgIGludCBzaXplPTA7Ly/RgNCw0LfQvNC10YAKICAgaW50IHN0b3JhZ2VbMTAwMF07Ly/QvNCw0YHRgdC40LIKICAgdm9pZCBwdXNoIChpbnQgbikvL9C00L7QsdCw0LLQu9C10L3QuNC1INGN0Lst0YLQsAogICB7CiAgICAgICBzdG9yYWdlW3NpemVdPW47IAogICAgICAgc2l6ZSsrOyAKICAgfQogICBpbnQgcG9wICgpIC8v0YPQtNCw0LvQtdC90LjQtSDRjdC7LdGC0LAKICAgewogICAgICAgaW50IGI9c3RvcmFnZVtzaXplLTFdOyAKICAgICAgIHNpemUtLTsgCiAgICAgICByZXR1cm4gYjsKICAgfQp9OwogCmludCBtYWluICgpCnsKICAgc3RhY2sgc3Q7CiAgIHN0cmluZyBzOwogICB3aGlsZSAoNTUpIAogICB7CiAgIAkgICBjaW4gPj4gczsKICAgICAgIGlmIChzPT0icHVzaCIpIAogICAgICAgewogICAgICAgICAgIGludCBuOwogICAgICAgICAgIGNpbiA+PiBuOwogICAgICAgICAgIHN0LnB1c2gobik7CiAgICAgICAgICAgY291dCA8PCAib2tcbiI7CiAgICAgICB9CiAgICAgICBpZiAocz09InBvcCIpIAogICAgICAgewogICAgICAgIGlmIChzdC5zaXplPT0wKSAKICAgICAgICAgICB7CiAgICAgICAgICAgICAgIGNvdXQgPDwgImVycm9yXG4iOwogICAgICAgICAgIH0KICAgICAgICAgICBlbHNlIGNvdXQgPDwgc3QucG9wKCkgPDwgZW5kbDsKICAgICAgIH0gICAKICAgICAgIGlmIChzPT0iZXhpdCIpIAogICAgICAgewogICAgICAgICAgIGNvdXQgPDwgImJ5ZVxuIjsKICAgICAgICAgICBicmVhazsKICAgICAgIH0KICAgfQogICByZXR1cm4gMDsKfQo=