#include <bits/stdc++.h>
const int N = 100010;
using namespace std;
struct asd {
  int x, y, c;
  bool b;
} T[4 * N];
struct qwe {
  int x, y, z, num;
} a[N];
int i, j, l, k, p, n, tim[N], m, ans[N];
int cmp(qwe q, qwe p) { return (q.z < p.z || (q.z == p.z && q.num < p.num)); }
void build(int t, int l, int r) {
  T[t].x = l, T[t].y = r;
  T[t].c = 0;
  T[t].b = 0;
  if (l == r) return;
  int q = t << 1, m = (l + r) >> 1;
  build(q, l, m);
  build(q + 1, m + 1, r);
}
void down(int t) {
  if (T[t].x == T[t].y) return;
  int q = t << 1;
  if (T[t].b) {
    T[t].b = 0;
    T[q].b = T[q + 1].b = 1;
    T[q].c = T[q + 1].c = 0;
  }
}
void add(int t, int pos, int d) {
  down(t);
  if (T[t].y < pos || T[t].x > pos) return;
  if (T[t].x == T[t].y) {
    T[t].c += d;
    return;
  }
  int q = t << 1;
  add(q, pos, d);
  add(q + 1, pos, d);
  T[t].c = T[q].c + T[q + 1].c;
}
int cal(int t, int pos) {
  down(t);
  if (T[t].x > pos) return 0;
  if (T[t].y <= pos) return T[t].c;
  int q = t << 1;
  return (cal(q, pos) + cal(q + 1, pos));
}
int main() {
  scanf("%d", &n);
  memset(ans, -1, sizeof(ans));
  for (i = 1; i <= n; i++)
    scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z), tim[i] = a[i].y, a[i].num = i;
  sort(a + 1, a + 1 + n, cmp);
  sort(tim + 1, tim + 1 + n);
  m = unique(tim + 1, tim + 1 + n) - tim - 1;
  build(1, 1, m);
  a[0].z = -1;
  for (i = 1; i <= n; i++) {
    if (a[i].z != a[i - 1].z) T[1].c = 0, T[1].b = 1;
    p = lower_bound(tim + 1, tim + m + 1, a[i].y) - tim;
    if (a[i].x == 1) add(1, p, 1);
    if (a[i].x == 2) add(1, p, -1);
    if (a[i].x == 3) ans[a[i].num] = cal(1, p);
  }
  for (i = 1; i <= n; i++)
    if (ans[i] >= 0) printf("%d\n", ans[i]);
  return 0;
}
