Print Stack SizeEasy

Print Stack Size

EasyPractice library · +10 XPstack

You are given a sequence of operations to perform on an initially empty stack. The operations are 'push' and 'pop'. For each operation, you must first determine the size of the stack before the operation is performed, and then print this size. If a 'pop' operation is attempted on an empty stack, it is ignored (the stack remains empty), but you still print the size before the attempted pop (which is 0).

Input

The first line contains an integer N, the number of operations. The next N lines each contain a string, either "push" or "pop", representing an operation.

Output

Print N integers, each on a new line, representing the size of the stack before each operation.

Constraints

1 <= N <= 1000. Operations are either "push" or "pop".

Time limit 1 s (native code; slower languages get more)Memory 256 MB14 hidden tests

Example 1

Input
5
push
push
pop
push
pop
Output
0
1
2
1
2

Sizes before operations: 0, 1, 2, 1, 2.

Example 2

Input
3
pop
pop
push
Output
0
0
0

Sizes before operations: 0, 0, 0.

Hints