#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
int n, len, type[maxn], a[maxn], t[maxn], num[maxn];
map<int, int> s[maxn];
int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
  return x;
}
inline int lowbit(int x) { return x & (-x); }
void add(int p, int x, int k) {
  while (x <= len) s[p][x] += k, x += lowbit(x);
}
int query(int p, int x) {
  int sum = 0;
  while (x) sum += s[p][x], x -= lowbit(x);
  return sum;
}
int lsh(int *a, int n) {
  for (int i = 1; i <= n; i++) t[i] = a[i];
  sort(t + 1, t + n + 1);
  int len = unique(t + 1, t + n + 1) - t - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(t + 1, t + len + 1, a[i]) - t;
  return len;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) type[i] = read(), a[i] = read(), num[i] = read();
  lsh(num, n), len = lsh(a, n);
  for (int i = 1; i <= n; i++) {
    if (type[i] == 1)
      add(num[i], a[i], 1);
    else if (type[i] == 2)
      add(num[i], a[i], -1);
    else
      printf("%d\n", query(num[i], a[i]));
  }
  return 0;
}
