#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
map<int, int> H[maxn];
map<int, int> Vis;
int tot = 0;
int lowbit(int x) { return x & (-x); }
void update(int x, int t, int y) {
  for (int i = t; i < 1e9 + 5; i += lowbit(i)) H[x][i] += y;
}
int get(int x, int t) {
  int ans = 0;
  for (int i = t; i; i -= lowbit(i)) ans += H[x][i];
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1 && !Vis[y]) Vis[y] = ++tot;
    if (op == 1) update(Vis[y], x, 1);
    if (op == 2) update(Vis[y], x, -1);
    if (op == 3) printf("%d\n", get(Vis[y], x));
  }
}
