#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
struct node {
  int q, t, x;
  int id;
} a[N];
int Ans[N], lsh[N], tot = 0;
bool cmp(node a, node b) {
  if (a.x == b.x)
    return a.id < b.id;
  else
    return a.x < b.x;
}
int c[N];
int lowbit(int x) { return x & (-x); }
void add(int x, int v) {
  while (x <= 100000) {
    c[x] += v;
    x += lowbit(x);
  }
}
int ask(int x) {
  int ret = 0;
  while (x) {
    ret += c[x];
    x -= lowbit(x);
  }
  return ret;
}
bool cmp2(node a, node b) { return a.id < b.id; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i].q, &a[i].t, &a[i].x);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int l = 1, r = 1; l <= n; l = r + 1, r = l) {
    while (a[r].x == a[l].x) r++;
    r--;
    tot = 0;
    for (int j = l; j <= r; j++) lsh[++tot] = a[j].t;
    sort(lsh + 1, lsh + tot + 1);
    int siz = unique(lsh + 1, lsh + tot + 1) - lsh - 1;
    for (int j = l; j <= r; j++)
      a[j].t = lower_bound(lsh + 1, lsh + tot + 1, a[j].t) - lsh;
    for (int j = l; j <= r; j++) {
      if (a[j].q == 1) add(a[j].t, 1);
      if (a[j].q == 2) add(a[j].t, -1);
      if (a[j].q == 3) Ans[a[j].id] = ask(a[j].t);
    }
    for (int j = l; j <= r; j++) {
      if (a[j].q == 1) add(a[j].t, -1);
      if (a[j].q == 2) add(a[j].t, 1);
    }
  }
  sort(a + 1, a + n + 1, cmp2);
  for (int i = 1; i <= n; i++)
    if (a[i].q == 3) printf("%d\n", Ans[i]);
}
