#include <bits/stdc++.h>
using namespace std;
int n;
int s = 1000000005;
map<int, map<int, int> > mymap;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  while (n--) {
    int u, v, k;
    cin >> u >> v >> k;
    if (u == 1 || u == 2) {
      int gt = 1;
      if (u == 2) gt = -1;
      while (v <= s) {
        mymap[k][v] += gt;
        v = v + (v & (-v));
      }
    }
    if (u == 3) {
      int gt = 0;
      while (v > 0) {
        gt += mymap[k][v];
        v = v - (v & (-v));
      }
      cout << gt << "\n";
    }
  }
  return 0;
}
