#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int q, t, n, m;
map<int, map<int, int> > fen;
void update(int m, int x, int v) {
  while (m < 1e9) fen[x][m] += v, m += m & -m;
}
int qry(int m, int x) {
  int res = 0;
  while (m > 0) res += fen[x][m], m -= m & -m;
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> q;
  while (q--) {
    cin >> t >> m >> n;
    if (t == 1)
      update(m, n, 1);
    else if (t == 2)
      update(m, n, -1);
    else
      cout << qry(m, n) << endl;
  }
  return 0;
}
