A beacon logs pings and answers recency queries over a trailing window of width w. It processes q operations, each one of:
HIT t— record a ping at timet.COUNT t— report how many pings recorded so far have a time strictly greater thant - wand less than or equal tot(that is, within the trailing window(t - w, t]).
All timestamps t are given in non-decreasing order across the operations.
Input format
Line 1: two integers q and w.
Next q lines: HIT t or COUNT t.
Output format
For each COUNT operation, in order, print the number of pings in its trailing window.
Constraints
- 1 <= q <= 40
- 1 <= w <= 1000000
- 0 <= t <= 1000000, non-decreasing