#include <bits/stdc++.h>
using namespace std;
struct Node {
  int l, r;
  map<int, int> mp;
} node[5008611];
int a[5008611];
struct Node1 {
  int t, x, y;
} b[1008611];
void build(int l, int r, int rt) {
  node[rt].l = l, node[rt].r = r;
  int mid = (l + r) / 2;
  if (l < r) {
    build(l, mid, rt * 2);
    build(mid + 1, r, rt * 2 + 1);
  }
}
void push_down(int rt, int v) {
  if (node[rt].mp[v] != 0) {
    node[rt * 2].mp[v] += node[rt].mp[v];
    node[rt * 2 + 1].mp[v] += node[rt].mp[v];
    node[rt].mp[v] = 0;
  }
}
void update(int l, int r, int v, int rt, int kind) {
  int mid = (node[rt].l + node[rt].r) / 2;
  if (l == node[rt].l && r == node[rt].r) {
    if (kind == 1)
      node[rt].mp[v]++;
    else if (kind == 2)
      node[rt].mp[v]--;
    return;
  }
  push_down(rt, v);
  if (r <= mid) {
    update(l, r, v, rt * 2, kind);
  } else if (l > mid) {
    update(l, r, v, rt * 2 + 1, kind);
  } else {
    update(l, mid, v, rt * 2, kind);
    update(mid + 1, r, v, rt * 2 + 1, kind);
  }
}
int query(int day, int v, int rt) {
  int mid = (node[rt].l + node[rt].r) / 2;
  if (node[rt].l == node[rt].r && node[rt].l == day) {
    return node[rt].mp[v];
  }
  push_down(rt, v);
  if (day <= mid) {
    return query(day, v, rt * 2);
  } else {
    return query(day, v, rt * 2 + 1);
  }
}
int main() {
  int n, i, j, k = 0;
  scanf("%d", &n);
  int t, x, y;
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &b[i].t, &b[i].x, &b[i].y);
    a[++k] = b[i].t, a[++k] = b[i].x, a[++k] = b[i].y;
  }
  sort(a + 1, a + 1 + k);
  int len = unique(a + 1, a + 1 + k) - a - 1;
  build(1, len, 1);
  for (i = 1; i <= n; i++) {
    if (b[i].t == 1) {
      x = lower_bound(a + 1, a + 1 + len, b[i].x) - a;
      y = lower_bound(a + 1, a + 1 + len, b[i].y) - a;
      update(x, len, y, 1, 1);
    } else if (b[i].t == 2) {
      x = lower_bound(a + 1, a + 1 + len, b[i].x) - a;
      y = lower_bound(a + 1, a + 1 + len, b[i].y) - a;
      update(x, len, y, 1, 2);
    } else {
      x = lower_bound(a + 1, a + 1 + len, b[i].x) - a;
      y = lower_bound(a + 1, a + 1 + len, b[i].y) - a;
      int ans = query(x, y, 1);
      if (ans >= 0)
        printf("%d\n", ans);
      else
        printf("0\n");
    }
  }
  return 0;
}
