#include <bits/stdc++.h>
using namespace std;
struct node {
  int kind, time, val, id;
} q[101000];
int t[101000], cnt = 0, n;
int c[101000], mark[101000], ans[101000];
int compress(int num) { return lower_bound(t + 1, t + cnt + 1, num) - t; }
void add(int x, int val, int v) {
  while (x <= n) {
    if (mark[x] != val) {
      c[x] = v;
      mark[x] = val;
    } else {
      c[x] += v;
    }
    x += (x & -x);
  }
}
int sum(int x, int val) {
  int ret = 0;
  while (x > 0) {
    if (mark[x] == val) {
      ret += c[x];
    }
    x -= (x & -x);
  }
  return ret;
}
bool cmp(node x, node y) {
  if (x.val != y.val) {
    return x.val < y.val;
  }
  return x.id < y.id;
}
int main() {
  int i;
  scanf("%d", &n);
  ;
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d", &q[i].kind, &q[i].time, &q[i].val);
    ;
    q[i].id = i;
    t[++cnt] = q[i].time;
  }
  memset(ans, -1, sizeof(ans));
  int cnt1 = 0;
  sort(t + 1, t + cnt + 1);
  sort(q + 1, q + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    int num = compress(q[i].time);
    if (q[i].kind == 1) {
      add(num, q[i].val, 1);
    } else if (q[i].kind == 2) {
      add(num, q[i].val, -1);
    } else {
      ans[q[i].id] = sum(num, q[i].val);
    }
  }
  for (i = 1; i <= n; i++)
    if (ans[i] != -1) {
      printf("%d", ans[i]);
      ;
      printf("\n");
    }
  return 0;
}
