#include <bits/stdc++.h>
using namespace std;
int main() {
  int INF = 1e9;
  map<int, map<int, int> > decomp;
  int n;
  int a;
  int t;
  int x;
  int sum;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> t >> x;
    switch (a) {
      case 1:
        while (t < INF) {
          ++decomp[x][t];
          t += (t & -t);
        }
        break;
      case 2:
        while (t < INF) {
          --decomp[x][t];
          t += (t & -t);
        }
        break;
      case 3:
        for (sum = 0; t > 0; t -= (t & -t)) sum += decomp[x][t];
        cout << sum << endl;
        break;
    }
  }
  return 0;
}
