#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
map<int, int> mp;
struct node {
  int op, t, num, pos;
} a[maxn + 11], tmp[maxn + 11];
int ans[maxn + 11];
void cdq(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  cdq(l, mid);
  cdq(mid + 1, r);
  int i, j;
  int tot = l;
  for (i = l, j = mid + 1; i <= mid && j <= r;) {
    if (a[i].t < a[j].t) {
      if (a[i].op == 1)
        mp[a[i].pos]++;
      else if (a[i].op == 2)
        mp[a[i].pos]--;
      tmp[tot++] = a[i++];
    } else {
      if (a[j].op == 3) ans[a[j].num] += mp[a[j].pos];
      tmp[tot++] = a[j++];
    }
  }
  while (i <= mid) {
    if (a[i].op == 1)
      mp[a[i].pos]++;
    else if (a[i].op == 2)
      mp[a[i].pos]--;
    tmp[tot++] = a[i++];
  }
  while (j <= r) {
    ans[a[j].num] += mp[a[j].pos];
    tmp[tot++] = a[j++];
  }
  mp.clear();
  for (int i = l; i <= r; i++) a[i] = tmp[i];
}
bool cmp(node a, node b) { return a.num < b.num; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i].op, &a[i].t, &a[i].pos);
    a[i].num = i;
  }
  cdq(1, n);
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++)
    if (a[i].op == 3) printf("%d\n", ans[i]);
}
