#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
struct num {
  int key, id;
  num(int key_ = 0, int id_ = 0) {
    key = key_;
    id = id_;
  }
} t_[MAXN], x_[MAXN];
struct que {
  int op, t, x, id;
  que(int op_ = 0, int t_ = 0, int x_ = 0, int id_ = 0) {
    op = op_;
    t = t_;
    x = x_;
    id = id_;
  }
} q[MAXN];
int m, t[MAXN], top, st1[MAXN], st2[MAXN], ans[MAXN], n;
bool cmp(num x, num y) { return x.key < y.key; }
bool cmp2(que x, que y) {
  if (x.x == y.x) return x.id < y.id;
  return x.x < y.x;
}
int lowbit(int x) { return x & (-x); }
void update(int x, int y) {
  while (x <= m) {
    t[x] = t[x] + y;
    x = x + lowbit(x);
  }
}
int query(int x) {
  int re = 0;
  while (x) {
    re = re + t[x];
    x = x - lowbit(x);
  }
  return re;
}
void clear() {
  while (top) {
    update(st1[top], st2[top]);
    top--;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &q[i].op, &t_[i].key, &x_[i].key);
    t_[i].id = i;
    x_[i].id = i;
    q[i].id = i;
  }
  sort(t_ + 1, t_ + 1 + n, cmp);
  sort(x_ + 1, x_ + 1 + n, cmp);
  m = 1;
  q[t_[1].id].t = 1;
  for (int i = 2; i <= n; i++) {
    if (t_[i].key != t_[i - 1].key) m++;
    q[t_[i].id].t = m;
  }
  int cnt = 1;
  q[x_[1].id].x = 1;
  for (int i = 2; i <= n; i++) {
    if (x_[i].key != x_[i - 1].key) cnt++;
    q[x_[i].id].x = cnt;
  }
  sort(q + 1, q + 1 + n, cmp2);
  memset(ans, -1, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    if (q[i].x != q[i - 1].x) {
      clear();
    }
    if (q[i].op == 1) {
      top++;
      st1[top] = q[i].t;
      st2[top] = -1;
      update(q[i].t, 1);
    } else if (q[i].op == 2) {
      top++;
      st1[top] = q[i].t;
      st2[top] = 1;
      update(q[i].t, -1);
    } else {
      ans[q[i].id] = query(q[i].t);
    }
  }
  for (int i = 1; i <= n; i++)
    if (ans[i] != -1) printf("%d\n", ans[i]);
}
