#include <bits/stdc++.h>
using namespace std;
int N = 1000000000;
map<long long int, map<long long int, long long int>> BIT;
void update(long long int time, long long int val, long long int cc) {
  for (; time <= N; time += time & -time) BIT[time][val] += cc;
}
long long int query(long long int time, long long int vl) {
  long long int sum = 0;
  for (; time > 0; time -= time & -time) sum += BIT[time][vl];
  return sum;
}
int main() {
  long long int n;
  cin >> n;
  long long int ty, t, vl;
  while (n--) {
    cin >> ty >> t >> vl;
    if (ty == 1)
      update(t, vl, 1);
    else if (ty == 2)
      update(t, vl, -1);
    else
      cout << query(t, vl) << "\n";
  }
  return 0;
}
