You are building a counter that reports how many events happened during the last W seconds.
The first line gives q and the window width W. Then q commands follow, each carrying a timestamp t. Timestamps across the whole command stream are non-decreasing (each command's t is greater than or equal to the previous command's t).
Support two commands:
HIT t— record one hit that occurred at timet. Produces no output. (Multiple hits may share the same timestamp.)COUNT t— print how many recorded hits have a timestamp strictly greater thant - Wand less than or equal tot; that is, hits lying in the half-open interval(t - W, t].
Input format
Line 1: two integers q and W.
Each of the next q lines is HIT t or COUNT t.
Output format
For each COUNT command, print a single integer: the number of hits inside the window (t - W, t]. Print the answers in command order, one per line.
Constraints
- 1 ≤ q ≤ 100000
- 1 ≤ W ≤ 1000000000
- 1 ≤ t ≤ 1000000000
- Timestamps are non-decreasing across the command stream.