#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
map<int, int> s[N];
int n, a[N], t[N], x[N], pool[N], mx, m;
void add(int u, int x, int val) {
  while (u <= n) {
    s[u][x] += val;
    u += (u & -u);
  }
}
int cnt(int u, int x) {
  int ans = 0;
  while (u) {
    ans += s[u][x];
    u -= (u & -u);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++)
    scanf("%d%d%d", &a[i], &t[i], &x[i]), pool[i] = t[i];
  sort(pool + 1, pool + n + 1);
  int m = unique(pool + 1, pool + n + 1) - (pool + 1);
  mx = *max_element(pool + 1, pool + m + 1);
  for (register int i = 1; i <= n; i++) {
    t[i] = lower_bound(pool + 1, pool + m + 1, t[i]) - pool;
    if (a[i] == 1) {
      add(t[i], x[i], 1);
    } else if (a[i] == 2) {
      add(t[i], x[i], -1);
    } else if (a[i] == 3) {
      printf("%d\n", cnt(t[i], x[i]));
    }
  }
  return 0;
}
