#include <bits/stdc++.h>
const int inf = (int)1e9 + 1;
const int mod = 1e9 + 7;
using namespace std;
int size = 0;
struct node {
  int y;
  int l, r;
  node() {
    l = r = 0;
    y = 0;
  }
} d[11000011];
map<int, int> h;
void upd(int id, int cnt, int v, int tl = 1, int tr = inf) {
  if (!v || tl > id || tr < id || tl > tr) {
    return;
  }
  if (tl == tr) {
    d[v].y += cnt;
    return;
  }
  int mid = (tl + tr) / 2;
  if (id > mid) {
    if (!d[v].r) {
      d[v].r = ++size;
    }
    upd(id, cnt, d[v].r, mid + 1, tr);
  } else {
    if (!d[v].l) {
      d[v].l = ++size;
    }
    upd(id, cnt, d[v].l, tl, mid);
  }
  d[v].y = d[d[v].l].y + d[d[v].r].y;
}
int get(int r, int v, int tl = 1, int tr = inf) {
  if (tl > r || !v || tl > tr) {
    return 0;
  }
  if (tr <= r) {
    return d[v].y;
  } else {
    int mid = (tl + tr) / 2;
    return get(r, d[v].l, tl, mid) + get(r, d[v].r, mid + 1, tr);
  }
}
int t[100011], x[100011], y[100011];
int n;
int a[100011];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  for (int i = 1; i <= n; i++) {
    if (t[i] == 1) {
      if (!h[y[i]]) {
        h[y[i]] = ++size;
      }
      upd(x[i], 1, h[y[i]]);
    } else if (t[i] == 2) {
      if (!h[y[i]]) {
        h[y[i]] = ++size;
      }
      upd(x[i], -1, h[y[i]]);
    } else {
      if (!h[y[i]]) {
        h[y[i]] = ++size;
      }
      cout << get(x[i], h[y[i]]) << "\n";
    }
  }
  return 0;
}
