#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e9 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
struct node {
  int l, r, val;
  node() { l = r = val = 0; }
} t[10000000];
map<int, int> y;
int n, aa, bb, cc, len;
void update(bool type, int x, int v, int tl = 1, int tr = N) {
  if (tl == tr) {
    if (!type)
      t[v].val++;
    else
      t[v].val--;
    return;
  }
  int mid = (tl + tr) / 2;
  if (x <= mid) {
    if (!t[v].l) t[v].l = ++len;
    update(type, x, t[v].l, tl, mid);
  } else {
    if (!t[v].r) t[v].r = ++len;
    update(type, x, t[v].r, mid + 1, tr);
  }
  t[v].val = t[t[v].l].val + t[t[v].r].val;
}
int get(int x, int v, int tl = 1, int tr = N) {
  if (!v || tl > x) return 0;
  if (tr <= x) return t[v].val;
  int mid = (tl + tr) / 2;
  return get(x, t[v].l, tl, mid) + get(x, t[v].r, mid + 1, tr);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &aa, &bb, &cc);
    if (!y[cc]) y[cc] = ++len;
    if (aa == 3) {
      printf("%d\n", get(bb, y[cc]));
    } else {
      update(aa - 1, bb, y[cc]);
    }
  }
  return 0;
}
