#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const int maxn = 1e5 + 10;
const double eps = 1e-8;
const double PI = acos(-1.0);
map<int, int> sum[100010], vis;
void update(int time, int x, int val) {
  while (time < MOD) {
    sum[x][time] += val;
    time += ((time) & (-time));
  }
}
int query(int time, int x) {
  int ans = 0;
  while (time > 0) {
    ans += sum[x][time];
    time -= ((time) & (-time));
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  int id = 0;
  vis.clear();
  for (int i = 0; i < n; i++) {
    int op, t, x;
    scanf("%d%d%d", &op, &t, &x);
    if (op == 1 && !vis[x]) vis[x] = ++id;
    if (op == 1) update(t, vis[x], 1);
    if (op == 2) update(t, vis[x], -1);
    if (op == 3) printf("%d\n", query(t, vis[x]));
  }
  return 0;
}
