import sys N, K, Q = map(int, input().split()) li = list() query = sys.stdin.read().splitlines() i = 0 lq = len(query) while i < lq: line = query[i] if line == "1": i += 1 li.append(query[i]) elif line == "2": ans = 0 time = 0 tmp_li = list() M = len(li) k = M - N for j in range(6): lili = li[k:] print(lili) i += 1 t, d = query[i].split() tmp_li.append(t) d = int(d) if t in lili: d = min(d, K) time += d if time <= 60: ans += 1 for j in range(6): li.append(tmp_li[j]) print(ans) i += 1