#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
map<int, int> mp;
unordered_map<int, unordered_map<int, int>> mq;
int a[N], b[N], c[N], n, m = 0;
void add(int x, int p, int v) {
  for (int i = p; i <= n; i += (i & -i)) mq[x][i] += v;
}
int que(int x, int p) {
  int ans = 0;
  for (int i = p; i; i -= (i & -i)) ans += mq[x][i];
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    mp[b[i]] = 0;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) it->second = ++m;
  for (int i = 1; i <= n; i++) b[i] = mp[b[i]];
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      add(c[i], b[i], 1);
    else if (a[i] == 2)
      add(c[i], b[i], -1);
    else
      printf("%d\n", que(c[i], b[i]));
  }
}
