#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct cdq {
  int x, y, op, id;
  int kkr;
} v[N];
int cnt[N], b[N], tot, n;
bool cmp(cdq x, cdq y) { return x.x < y.x; }
bool cmp2(cdq x, cdq y) { return x.id < y.id; }
void add(int x, int y) {
  int p = 0;
  if (y == 1 || y == -2) p = 1;
  if (y == 2 || y == -1) p = -1;
  cnt[x] += p;
}
void slove(int l, int r) {
  if (l == r) return;
  int mid = l + r >> 1, j = l;
  slove(l, mid);
  slove(mid + 1, r);
  sort(v + l, v + mid + 1, cmp);
  sort(v + mid + 1, v + r + 1, cmp);
  for (int i = mid + 1; i <= r; i++) {
    while (v[i].x >= v[j].x && j <= mid) add(v[j].y, v[j].op), j++;
    v[i].kkr += cnt[v[i].y];
  }
  for (int i = l; i < j; i++) add(v[i].y, -v[i].op);
  j = r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &v[i].op, &v[i].x, &v[i].y);
    b[i] = v[i].y, v[i].id = i;
  }
  sort(b + 1, b + n + 1);
  tot = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; i++)
    v[i].y = lower_bound(b + 1, b + tot + 1, v[i].y) - b;
  slove(1, n);
  sort(v + 1, v + n + 1, cmp2);
  for (int i = 1; i <= n; i++) {
    if (v[i].op == 3) printf("%d\n", v[i].kkr);
  }
}
