#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
const int MAXN = 111111;
int n;
int tp[MAXN], t[MAXN], x[MAXN], ans[MAXN];
int xx[MAXN], xn;
vector<int> v[MAXN];
vector<int> val, vt;
void add(int x, int v) {
  for (; x < ((int)(val.size())); x += x & -x) val[x] += v;
}
int get(int x) {
  int ret = 0;
  for (; x; x -= x & -x) ret += val[x];
  return ret;
}
void solve(int id) {
  val.clear();
  vt.clear();
  for (int i = 0; i < ((int)(v[id].size())); i++) {
    int idx = v[id][i];
    vt.push_back(t[idx]);
  }
  sort((vt).begin(), (vt).end());
  vt.erase(unique((vt).begin(), (vt).end()), vt.end());
  val.resize(((int)(vt.size())) + 1);
  for (int i = 0; i < ((int)(v[id].size())); i++) {
    int idx = v[id][i];
    int p = lower_bound((vt).begin(), (vt).end(), t[idx]) - vt.begin() + 1;
    if (tp[idx] == 1) {
      add(p, 1);
    } else if (tp[idx] == 2) {
      add(p, -1);
    } else {
      ans[idx] = get(p);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", tp + i, t + i, x + i);
    xx[i] = x[i];
  }
  sort(xx, xx + n);
  xn = unique(xx, xx + n) - xx;
  for (int i = 0; i < n; i++) {
    int p = lower_bound(xx, xx + xn, x[i]) - xx;
    v[p].push_back(i);
  }
  for (int i = 0; i < xn; i++) {
    solve(i);
  }
  for (int i = 0; i < n; i++) {
    if (tp[i] == 3) {
      printf("%d\n", ans[i]);
    }
  }
  return 0;
}
