#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int bit[maxn];
int ans[maxn];
int n;
struct qry {
  int type;
  int id;
  int val;
  int mom;
} qr[maxn];
qry stay[maxn];
bool cmp(qry a, qry b) {
  if (a.val != b.val)
    return a.val < b.val;
  else
    return a.mom < b.mom;
}
void upd(int id, int val) {
  for (int i = id; i <= n; i += i & -i) {
    bit[i] += val;
  }
}
int sum(int id) {
  int res = 0;
  for (int i = id; i > 0; i -= i & -i) {
    res += bit[i];
  }
  return res;
}
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> qr[i].type >> qr[i].mom >> qr[i].val;
    qr[i].id = i;
    stay[i] = qr[i];
    bit[i] = 0;
  }
  int las = 1;
  sort(qr + 1, qr + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    if (i != 1 && qr[i].val != qr[i - 1].val) {
      for (int j = las; j < i; j++) {
        if (qr[j].type == 1) upd(qr[j].id, -1);
        if (qr[j].type == 2) upd(qr[j].id, 1);
      }
      las = i;
    }
    if (qr[i].type == 1) {
      upd(qr[i].id, 1);
    }
    if (qr[i].type == 2) {
      upd(qr[i].id, -1);
    }
    if (qr[i].type == 3) {
      ans[qr[i].id] = sum(qr[i].id);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (stay[i].type == 3) {
      cout << ans[stay[i].id] << "\n";
    }
  }
}
