#include <bits/stdc++.h>
using namespace std;
unordered_map<int, unordered_map<int, int> > bit;
const int N = (1 << 30);
void add(int t, int x, int d) {
  while (x < N) bit[t][x] += d, x += x & -x;
}
int qry(int t, int x) {
  int ret = 0;
  while (x) ret += bit[t][x], x -= x & -x;
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  int tp, t, x;
  while (n--) {
    scanf("%d%d%d", &tp, &t, &x);
    if (tp == 3)
      printf("%d\n", qry(x, t));
    else
      add(x, t, (tp == 1 ? 1 : -1));
  }
  return 0;
}
