import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); ArrayList order = new ArrayList<>(); ArrayList current = new ArrayList<>(); current.add(Long.MIN_VALUE); current.add(Long.MAX_VALUE); long added = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int t = sc.nextInt(); int x = sc.nextInt(); if (t == 1) { int left = 0; int right = current.size() - 1; long y = x - added; while (right - left > 1) { int m = (left + right) / 2; if (current.get(m) <= y) { left = m; } else { right = m; } } current.add(right, y); order.add(y); } else if (t == 2) { current.remove(order.get(x - 1)); } else { added += x; } int left = 0; int right = current.size() - 1; while(right - left > 1) { int m = (left + right) / 2; if (current.get(m) + added >= current.size() - m - 1) { right = m; } else { left = m; } } sb.append(current.size() - right - 1).append("\n"); } System.out.print(sb); } }