Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Mr. Tom and Relief Goods

By jisan047 · Limits 1s, 512 MB

Mr. Tom wants to help war-affected people by giving them shirts. For this he collects shirt from those who really want to help. Actually, we all should have a responsibility to help people. We salute Mr. Tom for his plan. We should stop the war, it hurts :-(. Anyway now I'm telling the way of help planned by Mr. Tom.He managed a big box, in it, he stores the shirts. At any time There is two events to occur.

  1. Someone give him a shirt with size A as relief good. This shirt stores at the top of the box.
  2. Someone wants a shirt with size A. And he gets all the shirts above the shirt with size A and the shirt with size A as well. To help as many people as possible, he tries to give shirts to a people as few as possible. If there is no shirt with size A he can't get any shirt.

Can you guess how many shirts one can have?

Input

Input starts with N denoting the number of occurrences.
Next, N lines describe the events with the format type A denoting the event type and the size of the shirt, respectively

Constraints

1 <= N <= 1000
1 <= type <= 2
1 <= A <= 50

Output

For each query of the second type print an integer denoting the number of shirts the war-affected people get. If there is no shirt with size A in the box simply print "Sorry".

Sample

InputOutput
5
1 1
1 2
1 3
2 2
2 1
2
1

Discussion

Statistics


68% Solution Ratio

Tanzir5Earliest, Mar '18

MuhammadHalabyFastest, 0.0s

Tanzir5Lightest, 131 kB

ahadruShortest, 377B

Submit

Login to submit

Related Contests

Toph uses cookies. By continuing you agree to our Cookie Policy.