#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int n;
unordered_map<int, int> bit[MAX];
unordered_map<int, int> idx;
int inf = 1000000001;
void update(int pos, int t, int val) {
  for (; t < inf; t += (t & -t)) {
    bit[pos][t] += val;
  }
}
int get(int pos, int t) {
  int ans = 0;
  for (; t > 0; t -= (t & -t)) ans += bit[pos][t];
  return ans;
}
int main() {
  int type, t, x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &type, &t, &x);
    if (!idx.count(x)) idx[x] = i;
    int cur = idx[x];
    if (type == 1) {
      update(idx[x], t, 1);
    }
    if (type == 2) {
      update(idx[x], t, -1);
    }
    if (type == 3) {
      int ans = get(idx[x], t);
      printf("%d\n", ans);
    }
  }
  return 0;
}
