#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
map<int, int> s[1010011], vis;
int lowbit(int x) { return x & -x; }
void add(int k, int x, int v) {
  while (k < 1e9 + 7) {
    s[x][k] += v;
    k += lowbit(k);
  }
}
int ans(int k, int x) {
  int res = 0;
  while (k) {
    res += s[x][k];
    k -= lowbit(k);
  }
  return res;
}
int cnt = 0;
int q[2002002], t[2020002], x[2020022];
int y[2020022];
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) {
    q[i] = read(), t[i] = read(), x[i] = read();
    y[i] = x[i];
  }
  sort(y + 1, y + n + 1);
  for (int i = 1; i <= n; i++) {
    if (y[i] != y[i - 1]) {
      cnt++;
      vis[y[i]] = cnt;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (q[i] == 1) {
      add(t[i], vis[x[i]], 1);
    }
    if (q[i] == 2) {
      add(t[i], vis[x[i]], -1);
    }
    if (q[i] == 3) {
      cout << ans(t[i], vis[x[i]]) << endl;
    }
  }
  return 0;
}
