#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, type[N], tim[N], v[N];
map<int, int> ms[N];
map<int, int>::iterator it;
map<int, int> mp;
void add(int idx, int v) {
  while (idx < N - 2) {
    ++ms[idx][v];
    idx += idx & -idx;
  }
}
void remove(int idx, int v) {
  while (idx < N - 2) {
    --ms[idx][v];
    idx += idx & -idx;
  }
}
int get(int idx, int v) {
  int s = 0;
  while (idx > 0) {
    s += ms[idx][v];
    idx -= idx & -idx;
  }
  return s;
}
int main(int argc, char **argv) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &type[i], &tim[i], &v[i]);
    mp[tim[i]];
  }
  int id = 1;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it)
    it->second = id++;
  for (int i = 0; i < n; ++i) tim[i] = mp[tim[i]];
  for (int i = 0; i < n; ++i) {
    if (type[i] == 1) {
      add(tim[i], v[i]);
    } else if (type[i] == 2) {
      remove(tim[i], v[i]);
    } else {
      printf("%d\n", get(tim[i], v[i]));
    }
  }
  return 0;
}
