#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct node {
  int sta, xb, x, y;
  bool operator<(const node &a) const { return xb < a.xb; }
} p[maxn], q[maxn];
bool cmp(node a, node b) { return a.x < b.x; }
int yy[maxn];
int ans[maxn];
int num[maxn];
void cdq(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  cdq(l, mid);
  cdq(mid + 1, r);
  sort(p + l, p + 1 + r, cmp);
  for (int i = l; i <= r; i++) {
    if (p[i].xb <= mid) {
      num[p[i].y] += p[i].sta;
    } else {
      if (p[i].sta == 0) ans[p[i].xb] += num[p[i].y];
    }
  }
  for (int i = l; i <= r; i++) {
    if (p[i].xb <= mid) {
      num[p[i].y] -= p[i].sta;
    }
  }
  sort(p + l, p + 1 + r);
}
int main() {
  int n, op;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &op, &p[i].x, &p[i].y);
    p[i].xb = i;
    if (op == 1)
      p[i].sta = 1;
    else if (op == 2)
      p[i].sta = -1;
    else
      p[i].sta = 0;
    yy[i] = p[i].y;
  }
  sort(yy + 1, yy + 1 + n);
  int sz = unique(yy + 1, yy + 1 + n) - yy - 1;
  for (int i = 1; i <= n; i++)
    p[i].y = lower_bound(yy + 1, yy + 1 + sz, p[i].y) - yy;
  cdq(1, n);
  for (int i = 1; i <= n; i++)
    if (p[i].sta == 0) printf("%d\n", ans[i]);
  return 0;
}
