//e-olymp 6122. Простой стек
import java.util.*;
import java.lang.*;
import java.io.*;
Vector<Integer> storage;
{
storage = new Vector<Integer>();
}
void push(int number)
{
this.storage.add(number);
}
int pop()
{
int lastNumber = storage.lastElement();
storage.remove(storage.size() - 1);
return lastNumber;
}
int back()
{
int lastNumber = storage.lastElement();
return lastNumber;
}
int size()
{
return storage.size();
}
void clear()
{
storage.clear();
}
{
return "bye";
}
}
public class Main {
public static void main
(String[] args
) { Scanner input
= new Scanner
(System.
in); int number;
while(input.hasNextLine())
{
request = input.next();
if(request.equals("push"))
{
number = input.nextInt();
stack.push(number);
}
else if(request.
equals("pop")) System.
out.
println(stack.
pop()); else if(request.
equals("back")) System.
out.
println(stack.
back()); else if(request.
equals("size")) System.
out.
println(stack.
size()); else if(request.equals("clear"))
{
stack.clear();
}
else if(request.equals("exit"))
{
System.
out.
println(stack.
exit()); break;
}
}
}
}
Ly9lLW9seW1wIDYxMjIuINCf0YDQvtGB0YLQvtC5INGB0YLQtdC6CgppbXBvcnQgamF2YS51dGlsLio7CmltcG9ydCBqYXZhLmxhbmcuKjsKaW1wb3J0IGphdmEuaW8uKjsKCmNsYXNzIFN0YWNrIHsKCglWZWN0b3I8SW50ZWdlcj4gc3RvcmFnZTsKCQoJcHVibGljIFN0YWNrKCkKCXsKCQlzdG9yYWdlID0gbmV3IFZlY3RvcjxJbnRlZ2VyPigpOwoJfQoJCgl2b2lkIHB1c2goaW50IG51bWJlcikKCXsKCQl0aGlzLnN0b3JhZ2UuYWRkKG51bWJlcik7Cgl9CgkKCWludCBwb3AoKQoJewoJCWludCBsYXN0TnVtYmVyID0gc3RvcmFnZS5sYXN0RWxlbWVudCgpOwoJCXN0b3JhZ2UucmVtb3ZlKHN0b3JhZ2Uuc2l6ZSgpIC0gMSk7CgkJcmV0dXJuIGxhc3ROdW1iZXI7Cgl9CgkKCWludCBiYWNrKCkKCXsKCQlpbnQgbGFzdE51bWJlciA9IHN0b3JhZ2UubGFzdEVsZW1lbnQoKTsKC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