#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
class Stack
{
    public:
    Stack()
    {
        base=(int*)malloc(100*sizeof(int));
        top=0;
        size=100;
    }
    ~Stack()
    {
        free(base);
    }
    void push_back(int e)
    {
        kr();
        base[top++]=e;
    }
    void pop_back()
    {
        if(top==0) cout<<"Empty"<<endl;
        else top--;
    }
    void query()
    {
        if(top==0) cout<<"Empty"<<endl;
        else cout<<base[top-1]<<endl;
    }
    int size1()
    {
        return top;
    }
    private:
    int *base;
    int top;
    int size;
    void kr()
    {
        if(size==top)
        {
            base=(int*)realloc(base,(size+10)*sizeof(int));
            size+=10;
        }
    }
};
int main()
{
    int n;
    cin>>n;
    Stack ST;
    while(n--)
    {
        string s;
        cin>>s;
        int a=-1;
        if(s=="push") a=1;
        if(s=="pop") a=2;
        if(s=="query") a=3;
        if(s=="size") a=4;
        switch(a)
        {
            case 1:
            {
                int e;
                cin>>e;
                ST.push_back(e);
            }
            break;
            case 2:ST.pop_back();
            break;
            case 3:ST.query();
            break;
            case 4:cout<<ST.size1()<<endl;
            break;
            default:break;
        }
    }
    return 0;
}