#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
const long long inf = 0x3f3f3f3f3f3f3f3f;
std::map<int, int> c[maxn];
std::map<int, int> vis;
int n, cnt;
inline int lowbit(int x) { return x & -x; }
inline void update(int i, int val, int pos) {
  while (i < 1e9 + 5) {
    c[pos][i] += val;
    i += lowbit(i);
  }
}
inline int query(int i, int pos) {
  int ans = 0;
  while (i) {
    ans += c[pos][i];
    i -= lowbit(i);
  }
  return ans;
}
int main() {
  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] = ++cnt;
    if (op == 1) update(x, 1, vis[y]);
    if (op == 2) update(x, -1, vis[y]);
    if (op == 3) printf("%d\n", query(x, vis[y]));
  }
  return 0;
}
