Unlimited stack size#6124

Unlimited stack size

1 second
256 megabytes
Very easy

Implement a data structure called a stack. Write a program that defines a stack and simulates its operations by implementing all the methods detailed below. The program will read a sequence of commands and execute the corresponding operation for each command. After executing each command, the program should output a single line. The possible commands are:

push

Add the number to the stack (where is specified after the command). The program should output ok.

pop

Remove the last element from the stack and output its value.

back

Output the value of the last element without removing it from the stack.

size

Output the number of elements currently in the stack.

clear

Clear all elements from the stack and output ok.

exit

Output bye and terminate the program.

The stack's capacity should be limited only by the available RAM. Before performing the back or pop operations, the program should check that there is at least one element in the stack. If the stack is empty and a back or pop operation is requested, the program should output the string error instead of a numerical value.

Input

As described above. See the sample input for details.

Output

As described above. See the sample output for details.

Examples

Example 1

Loading
Loading