#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct op {
  int tp, sp, x, id;
  op() {}
  op(int a, int b, int c, int d) { tp = a, sp = b, x = c, id = d; }
  bool operator<(const op& a) const { return sp < a.sp; }
} qry[N];
map<int, int> st;
int ans[N];
bool vis[N] = {0};
int acnt = 0;
inline bool cmp(const op& a, const op& b) { return a.id < b.id; }
void CDQ(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) >> 1;
  CDQ(l, mid);
  CDQ(mid + 1, r);
  sort(qry + l, qry + r + 1);
  for (int i = l; i <= r; ++i) {
    op& x = qry[i];
    if (x.id <= mid) {
      if (x.tp == 1)
        st[x.x] += 1;
      else if (x.tp == 2)
        st[x.x] -= 1;
    } else {
      if (x.tp == 3) ans[x.id] += st[x.x];
    }
  }
  for (int i = l; i <= r; ++i) {
    op& x = qry[i];
    if (x.id <= mid) {
      if (x.tp == 1)
        st[x.x] -= 1;
      else if (x.tp == 2)
        st[x.x] += 1;
    }
  }
  sort(qry + l, qry + r + 1, cmp);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &qry[i].tp, &qry[i].sp, &qry[i].x);
    qry[i].id = i;
    if (qry[i].tp == 3) vis[i] = 1;
  }
  memset(ans, 0, sizeof(ans));
  CDQ(1, n);
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) printf("%d\n", ans[i]);
  }
}
