#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int a[N], t[N], x[N], h[N], n;
map<int, int> b[N];
void add(int x, int ty, int v) {
  for (; x <= n; x += x & (-x)) b[x][ty] += v;
}
int query(int x, int ty) {
  int ret = 0;
  for (; x > 0; x -= x & (-x)) ret += b[x][ty];
  return ret;
}
int find(int x) { return lower_bound(h + 1, h + 1 + n, x) - h; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i], &t[i], &x[i]);
    h[i] = t[i];
  }
  sort(h + 1, h + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      add(find(t[i]), x[i], 1);
    else if (a[i] == 2)
      add(find(t[i]), x[i], -1);
    else
      printf("%d\n", query(find(t[i]), x[i]));
  }
  return 0;
}
