#include <bits/stdc++.h>
using namespace std;
int n;
int op[100005], t[100005], x[100005], tmp[100005], sz[100005], num;
vector<int> g[100005];
vector<int>::iterator iter;
vector<int> a[100005][2];
void san() {
  for (int i = 1; i <= n; ++i) tmp[i] = x[i];
  sort(tmp + 1, tmp + 1 + n);
  int num = unique(tmp + 1, tmp + 1 + n) - (tmp + 1);
  for (int i = 1; i <= n; ++i)
    x[i] = lower_bound(tmp + 1, tmp + 1 + num, x[i]) - tmp;
  for (int i = 1; i <= num; ++i) g[i].clear();
  for (int i = 1; i <= n; ++i) g[x[i]].push_back(t[i]);
  for (int i = 1; i <= num; ++i) sort(g[i].begin(), g[i].end());
  for (int i = 1; i <= num; ++i)
    iter = unique(g[i].begin(), g[i].end()), g[i].erase(iter, g[i].end());
  for (int i = 1; i <= num; ++i) sz[i] = g[i].end() - g[i].begin();
  for (int i = 1; i <= n; ++i)
    t[i] =
        lower_bound(g[x[i]].begin(), g[x[i]].end(), t[i]) - g[x[i]].begin() + 1;
  for (int i = 1; i <= num; ++i) a[i][0] = vector<int>(((int)g[i].size() + 5));
  for (int i = 1; i <= num; ++i) a[i][1] = vector<int>(((int)g[i].size() + 5));
}
void add(int p, int pp, int x) {
  while (x <= sz[p]) {
    a[p][pp][x]++;
    x += x & (-x);
  }
}
int get(int p, int pp, int x) {
  int res = 0;
  while (x >= 1) {
    res += a[p][pp][x];
    x -= x & (-x);
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d%d", op + i, t + i, x + i);
  san();
  for (int i = 1; i <= n; ++i) {
    if (op[i] == 1) {
      add(x[i], 0, t[i]);
    } else if (op[i] == 2) {
      add(x[i], 1, t[i]);
    } else {
      printf("%d\n", get(x[i], 0, t[i]) - get(x[i], 1, t[i]));
    }
  }
  return 0;
}
