#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int fw[N];
void update(int u, int value) {
  while (u < N) {
    fw[u] += value;
    u += u & -u;
  }
}
int getSum(int u) {
  int ret = 0;
  while (u) {
    ret += fw[u];
    u -= u & -u;
  }
  return ret;
}
struct pnt {
  int a, t, x, id;
  pnt(int _a = 0, int _t = 0, int _x = 0, int _id = 0)
      : a(_a), t(_t), x(_x), id(_id) {}
  bool operator<(const pnt& op) const {
    if (x != op.x) return x < op.x;
    return id < op.id;
  }
} b[N];
int n;
pair<int, int> cm[N];
int c[N];
int ans[N];
map<int, int> mp;
pair<int, int> bk[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a, t, x;
    scanf("%d %d %d", &a, &t, &x);
    b[i] = pnt(a, t, x, i);
    cm[i] = make_pair(t, i);
  }
  sort(cm, cm + n);
  for (int i = 0; i < n; ++i) c[cm[i].second] = i + 1;
  sort(b, b + n);
  memset(ans, 0xff, sizeof ans);
  for (int i = 0; i < n;) {
    int j = i;
    int m = 0;
    for (; b[j].x == b[i].x; ++j) {
      int a = b[j].a;
      int id = b[j].id;
      int t = c[id];
      if (a == 1)
        update(t, 1), bk[m++] = make_pair(t, 1);
      else if (a == 2)
        update(t, -1), bk[m++] = make_pair(t, -1);
      else
        ans[id] = getSum(t);
    }
    i = j;
    for (j = 0; j < m; ++j) update(bk[j].first, -bk[j].second);
  }
  for (int i = 0; i < n; ++i)
    if (ans[i] != -1) printf("%d\n", ans[i]);
  return 0;
}
