#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int n;
struct node {
  int pos, a, t, x;
  bool operator<(const node &o) const { return pos < o.pos; }
};
node Q[N], tmp[N];
int ans[N];
void cdq(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) >> 1;
  cdq(l, mid);
  cdq(mid + 1, r);
  map<int, int> mp;
  int i = l, tot = l;
  for (int j = mid + 1; j <= r; ++j) {
    if (Q[j].a == 3) {
      while (i <= mid && Q[i].t <= Q[j].t) {
        if (Q[i].a == 1) {
          mp[Q[i].x]++;
        } else if (Q[i].a == 2) {
          mp[Q[i].x]--;
        }
        ++i;
      }
      ans[Q[j].pos] += mp[Q[j].x];
    }
  }
  i = l;
  for (int j = mid + 1; j <= r; ++j) {
    while (i <= mid && Q[i].t <= Q[j].t) {
      tmp[tot++] = Q[i];
      ++i;
    }
    tmp[tot++] = Q[j];
  }
  for (; i <= mid; ++i) tmp[tot++] = Q[i];
  for (int k = l; k <= r; ++k) Q[k] = tmp[k];
}
int main() {
  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;
  }
  cdq(1, n);
  sort(Q + 1, Q + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (Q[i].a == 3) {
      printf("%d\n", ans[i]);
    }
  }
  return 0;
}
