#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
map<int, map<int, int> > m;
int n, a, t, x, i, r;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d%d%d", &a, &t, &x);
    if (a == 1)
      while (t < INF) m[x][t]++, t += (t & -t);
    if (a == 2)
      while (t < INF) m[x][t]--, t += (t & -t);
    if (a == 3) {
      for (r = 0; t > 0; t -= (t & -t)) r += m[x][t];
      printf("%d\n", r);
    }
  }
  return 0;
}
