#include <bits/stdc++.h>
using namespace std;
bool Handsome;
inline void Mi(int &x, int y) {
  if (x > y && (x = y))
    ;
}
inline void Mx(int &x, int y) {
  if (x < y && (x = y))
    ;
}
const int M = 1e5 + 5;
int n, c[M], ct, ans[M], t[M];
bool mk[M];
struct node {
  int op, t, x, id;
} a[M], b[M];
void CDQ(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  CDQ(l, mid);
  CDQ(mid + 1, r);
  int p = l;
  for (int i = mid + 1, iend = r; i <= iend; ++i)
    if (a[i].op == 3) {
      while (p <= mid && a[p].t < a[i].t) {
        if (a[p].op == 1) ++t[a[p].x];
        if (a[p].op == 2) --t[a[p].x];
        ++p;
      }
      ans[a[i].id] += t[a[i].x];
    }
  while (p > l) t[a[--p].x] = 0;
  for (int i = l, iend = r; i <= iend; ++i) b[i] = a[i];
  int t = l;
  for (int i = mid + 1, iend = r; i <= iend; ++i) {
    while (p <= mid && b[p].t < b[i].t) a[t++] = b[p++];
    a[t++] = b[i];
  }
  while (p <= mid) a[t++] = b[p++];
}
bool Most;
int main() {
  scanf("%d", &n);
  for (int i = 1, iend = n; i <= iend; ++i) {
    scanf("%d%d%d", &a[i].op, &a[i].t, &a[i].x);
    c[i] = a[i].x;
    a[i].id = i;
    mk[i] = (a[i].op == 3);
  }
  sort(c + 1, c + n + 1);
  ct = unique(c + 1, c + n + 1) - c - 1;
  for (int i = 1, iend = n; i <= iend; ++i)
    a[i].x = lower_bound(c + 1, c + ct + 1, a[i].x) - c;
  CDQ(1, n);
  for (int i = 1, iend = n; i <= iend; ++i)
    if (mk[i]) printf("%d\n", ans[i]);
  return 0;
}
