#include <bits/stdc++.h>
using namespace std;
const unsigned maxDegree = 30;
map<int, map<int, int>> s;
inline unsigned ind(unsigned int x) {
  unsigned p(0);
  while (x >>= 1) ++p;
  return p;
}
inline unsigned lowbit(int x) { return (x & -x); }
int main() {
  int n;
  cin >> n;
  for (auto i = 0; i < n; ++i) {
    int a, t, x;
    cin >> a >> t >> x;
    if (a == 1) {
      while (t < 1e9 + 1) {
        ++s[x][t];
        t += lowbit(t);
      }
    } else if (a == 2) {
      while (t < 1e9 + 1) {
        --s[x][t];
        t += lowbit(t);
      }
    } else if (a == 3) {
      int res(0);
      while (t > 0) {
        res += s[x][t];
        t -= lowbit(t);
      }
      cout << res << endl;
    }
  }
  return 0;
}
