#include <bits/stdc++.h>
using namespace std;
int n, m, k, T, sum[2 * 100086], t[2 * 100086], tmp[100086], a[100086],
    b[100086], c[100086];
int lowbit(int x) { return x & -x; }
struct node {
  int a, b, c, cnt, ans, opt;
} s1[2 * 100086], s2[2 * 100101];
bool cmp1(node a, node b) { return a.a < b.a; }
bool cmp2(node a, node b) { return a.b < b.b; }
void lsh(int *a, int n) {
  for (int i = 1; i <= n; ++i) tmp[i] = a[i];
  sort(tmp + 1, tmp + n + 1);
  int l = unique(tmp + 1, tmp + n + 1) - tmp - 1;
  for (int i = 1; i <= n; ++i)
    a[i] = lower_bound(tmp + 1, tmp + l + 1, a[i]) - tmp;
}
void CDQ(int l, int r) {
  if (l == r) return;
  int mid = (l + r) / 2;
  CDQ(l, mid);
  CDQ(mid + 1, r);
  sort(s1 + l, s1 + mid + 1, cmp2);
  sort(s1 + mid + 1, s1 + r + 1, cmp2);
  int j = l;
  for (int i = mid + 1; i <= r; i++) {
    while (s1[i].b >= s1[j].b && j <= mid) {
      if (s1[j].opt != 3) t[s1[j].c] += (s1[j].opt == 1 ? 1 : -1);
      j++;
    }
    if (s1[i].opt == 3) sum[s1[i].a] += t[s1[i].c];
  }
  for (int i = l; i < j; i++)
    if (s1[i].opt != 3) t[s1[i].c] -= (s1[i].opt == 1 ? 1 : -1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
  }
  lsh(b, n);
  lsh(c, n);
  for (int i = 1; i <= n; i++) {
    s1[i].a = i;
    s1[i].b = b[i];
    s1[i].c = c[i];
    s1[i].opt = a[i];
  }
  CDQ(1, n);
  sort(s1 + 1, s1 + 1 + n, cmp1);
  for (int i = 1; i <= n; i++)
    if (s1[i].opt == 3) cout << sum[i] << endl;
}
