N, K, Q = map(int, input().split()) A = [] for _ in range(Q): q = int(input()) if q == 1: A.append(input()) elif q == 2: M = len(A) B = A[max(0, M - N):] ans = 0 time = 0 done = [] for i in range(6): t, d = input().split() d = int(d) if t in B: if time + min(d, K) <= 60: ans += 1 done.append(t) time += min(d, K) else: if time + d <= 60: ans += 1 done.append(t) time += d print(ans) A.extend(done)