#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000010;
int n, res[maxN], check[maxN], t[maxN];
struct query {
  int a, t, v, p, tmp_p;
};
query q[maxN], tmp_q[maxN];
void update(int x, int v) {
  while (x <= n) {
    t[x] += v;
    x += (x & (-x));
  }
}
int get(int x) {
  int tmp = 0;
  while (x) {
    tmp += t[x];
    x -= (x & (-x));
  }
  return tmp;
}
bool cmp_t(query i, query j) { return i.t < j.t; }
bool cmp_v(query i, query j) { return i.v < j.v || (i.v == j.v && i.p < j.p); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d %d", &q[i].a, &q[i].t, &q[i].v);
    q[i].p = i;
    check[i] = (q[i].a == 3);
  }
  sort(q + 1, q + n + 1, cmp_v);
  int k = 0, start_time = 0;
  for (int i = 1; i <= n + 1; ++i) {
    if (q[i].v != q[i - 1].v || i == 1 || i == n + 1) {
      sort(tmp_q + 1, tmp_q + k + 1, cmp_t);
      for (int j = 1; j <= k; ++j) q[tmp_q[j].tmp_p].t = j + start_time - 1;
      for (int j = start_time; j <= i - 1; ++j) {
        if (q[j].a == 1) update(q[j].t, 1);
        if (q[j].a == 2) update(q[j].t, -1);
        if (q[j].a == 3) res[q[j].p] = get(q[j].t) - get(start_time - 1);
      }
      start_time = i, k = 0;
    }
    tmp_q[++k] = q[i];
    tmp_q[k].tmp_p = i;
  }
  for (int i = 1; i <= n; ++i)
    if (check[i]) printf("%d\n", res[i]);
}
