#include <bits/stdc++.h>
using namespace std;
int n, m, tot;
int a, b, T;
long long K;
typedef struct Ed {
  int s, i, t, x, nxt;
  friend int operator<(struct Ed x, struct Ed y) { return x.x > y.x; }
} E;
const double pi = 4 * atan(1);
long long mpow(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % p;
    y = y >> 1;
    x = x * x % p;
  }
  return res;
}
long long qpow(long long x, int y) {
  long long res = 1;
  int i = 0;
  while (y) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long gcd(long long x, long long y) {
  while (y) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}
double mabs(double x) {
  if (x < 0) return -x;
  return x;
}
int mcmp(int *x, int *y) { return (*x) < (*y); }
void readline(char *x) {
  int l = 0;
  char c;
  while (scanf("%c", &c) != EOF && c != '\n') x[l++] = c;
  if (l == 0)
    while (scanf("%c", &c) != EOF && c != '\n') x[l++] = c;
  x[l] = 0;
}
E e[100007];
int tq[100007], xq[100007];
int xn, tn;
queue<int> g[100007];
int tr[100007 * 3], ts[100007 * 3];
void PUSH(int d, int l, int r) {
  if (ts[d]) {
    tr[d] = 0;
    ts[d] = 0;
    if (l != r) {
      ts[d << 1] = 1;
      ts[(d << 1) + 1] = 1;
    }
  }
}
void tadd(int d, int l, int r, int x, int y, int c) {
  if (l > r || x > y || x < l || y > r) return;
  if (l == x && y == r) {
    PUSH(d, l, r);
    tr[d] += c;
    return;
  }
  PUSH(d, l, r);
  if (tr[d] != 0) {
    if (l != r) {
      PUSH(d << 1, l, l + r >> 1);
      PUSH((d << 1) + 1, (l + r >> 1) + 1, r);
      tr[d << 1] += tr[d];
      tr[(d << 1) + 1] += tr[d];
    }
    tr[d] = 0;
  }
  int o = l + r >> 1, ll = d << 1, rr = ll + 1;
  if (y <= o)
    tadd(ll, l, o, x, y, c);
  else if (x > o)
    tadd(rr, o + 1, r, x, y, c);
  else
    tadd(ll, l, o, x, o, c), tadd(rr, o + 1, r, o + 1, y, c);
}
int tfind(int d, int l, int r, int x) {
  if (l > r || x < l || x > r) return 0;
  if (l == r) {
    if (ts[d]) {
      tr[d] = 0;
      ts[d] = 0;
    }
    return tr[d];
  }
  PUSH(d, l, r);
  if (tr[d] != 0) {
    if (l != r) {
      PUSH(d << 1, l, l + r >> 1);
      PUSH((d << 1) + 1, (l + r >> 1) + 1, r);
      tr[d << 1] += tr[d];
      tr[(d << 1) + 1] += tr[d];
    }
    tr[d] = 0;
  }
  int o = l + r >> 1, ll = d << 1, rr = ll + 1;
  if (x <= o)
    return tfind(ll, l, o, x);
  else if (x > o)
    return tfind(rr, o + 1, r, x);
}
int main(void) {
  T = 1;
  for (int ci = 1; ci <= T; ++ci) {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d%d%d", &e[i].s, &e[i].t, &e[i].x);
      e[i].i = i;
      xq[i] = e[i].x;
      tq[i] = e[i].t;
    }
    sort(xq, xq + n);
    xn = unique(xq, xq + n) - xq;
    sort(tq, tq + n);
    tn = unique(tq, tq + n) - tq;
    for (int i = 0; i < n; ++i) {
      e[i].x = lower_bound(xq, xq + xn, e[i].x) - xq;
      e[i].t = lower_bound(tq, tq + tn, e[i].t) - tq;
      g[e[i].x].push(i);
    }
    for (int i = 0; i < xn; ++i) {
      ts[1] = 1;
      while (!g[i].empty()) {
        int k = g[i].front();
        g[i].pop();
        if (e[k].s == 1) tadd(1, 1, tn, e[k].t + 1, tn, 1);
        if (e[k].s == 2) tadd(1, 1, tn, e[k].t + 1, tn, -1);
        if (e[k].s == 3) e[k].nxt = tfind(1, 1, tn, e[k].t + 1);
      }
    }
    for (int i = 0; i < n; ++i)
      if (e[i].s == 3) {
        printf("%d\n", e[i].nxt);
      }
  }
  return 0;
}
