#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
map<int, int> vis;
map<int, int> bit[maxn];
int lowbit(int x) { return x & -x; }
void add(int id, int t, int x) {
  for (int i = t; i < 1e9 + 5; i += lowbit(i)) bit[id][i] += x;
}
int sum(int id, int t) {
  int res = 0;
  for (int i = t; i > 0; i -= lowbit(i)) res += bit[id][i];
  return res;
}
int main() {
  scanf("%d", &n);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    int cmd, ti, val;
    scanf("%d%d%d", &cmd, &ti, &val);
    if (cmd == 1) {
      if (!vis[val]) vis[val] = ++tot;
      add(vis[val], ti, 1);
    }
    if (cmd == 2) add(vis[val], ti, -1);
    if (cmd == 3) printf("%d\n", sum(vis[val], ti));
  }
  return 0;
}
