#include <bits/stdc++.h>
using namespace std;
int n, q, t, x, ans, son;
map<int, int> FW[100050], H;
void upd(int bas, int pos, int v) {
  for (int t = bas; t <= (1e9); t += t & -t) FW[pos][t] += v;
}
int que(int bas, int pos) {
  ans = 0;
  for (int t = bas; t > 0; t -= t & -t) ans += FW[pos][t];
  return ans;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &q, &t, &x);
    if (q == 1 and H.find(x) == H.end()) H[x] = ++son;
    if (q < 3)
      upd(t, H[x], q & 1 ? 1 : -1);
    else
      printf("%d\n", que(t, H[x]));
  }
}
