#include <bits/stdc++.h>
using namespace std;
const int Maxx = 1e9;
int n, q;
map<int, map<int, int> > mp;
void Insert(int time, int val) {
  while (time <= Maxx) {
    mp[val][time]++;
    time += (time) & (-time);
  }
}
void Erase(int time, int val) {
  while (time <= Maxx) {
    mp[val][time]--;
    time += (time) & (-time);
  }
}
int Query(int time, int val) {
  int re = 0;
  while (time) {
    re += mp[val][time];
    time -= (time) & (-time);
  }
  return re;
}
int main() {
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int type, time, val;
    scanf("%d%d%d", &type, &time, &val);
    if (type == 1) {
      Insert(time, val);
    } else if (type == 2) {
      Erase(time, val);
    } else {
      printf("%d\n", Query(time, val));
    }
  }
  return 0;
}
