#include <bits/stdc++.h>
using namespace std;
struct data {
  int a, t, x, pos;
  bool operator<(data b) const {
    if (x != b.x)
      return x < b.x;
    else
      return pos < b.pos;
  }
} q[100005];
bool byTime(data a, data b) { return a.t < b.t; }
int n, tot = 0, ans[100005], t[131072 << 1];
inline void update(int x, int v) {
  for (x += 131072; x; x >>= 1) t[x] += v;
}
inline void del(int x) {
  for (x += 131072; x; x >>= 1) t[x] = 0;
}
inline int query(int x) {
  int ans = 0;
  for (int l = 131072, r = x + 131072 + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
    if ((l & 1) ^ 1) ans += t[l ^ 1];
    if (r & 1) ans += t[r ^ 1];
  }
  return ans;
}
inline void work(int st, int ed) {
  for (int i = st; i <= ed; i++) {
    if (q[i].a == 1) {
      update(q[i].t, 1);
    } else if (q[i].a == 2) {
      update(q[i].t, -1);
    } else {
      ans[q[i].pos] = query(q[i].t);
    }
  }
  for (int i = st; i <= ed; i++) {
    if (q[i].a != 3) del(q[i].t);
  }
}
int main() {
  memset(ans, -1, sizeof(ans));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &q[i].a, &q[i].t, &q[i].x);
    q[i].pos = i;
  }
  sort(q + 1, q + n + 1, byTime);
  for (int i = 1, now = -1; i <= n; i++) {
    if (q[i].t != now) {
      now = q[i].t;
      q[i].t = ++tot;
    } else
      q[i].t = tot;
  }
  sort(q + 1, q + n + 1);
  for (int i = 1; i <= n; i++) {
    int now = q[i].x, j = i;
    for (; j < n && q[j + 1].x == now; j++)
      ;
    work(i, j);
    i = j;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] != -1) printf("%d\n", ans[i]);
  }
  return 0;
}
