#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;
}
