#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
vector<map<int, int>> tree;
void upd(int l, int d) {
  for (; l < tree.size(); l |= l + 1) tree[l][d]++;
}
void del(int l, int d) {
  for (; l < tree.size(); l |= l + 1) tree[l][d]--;
}
int ans(int r, int d) {
  int a = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) a += tree[r][d];
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> sj;
  int s = 0;
  vector<pair<int, pair<int, int>>> q(n);
  for (int i = 0; i < n; ++i) {
    cin >> q[i].first >> q[i].second.first >> q[i].second.second;
    sj[q[i].second.first] = 0;
  }
  for (auto& i : sj) {
    i.second = s;
    ++s;
  }
  tree.resize(s + 1);
  for (int i = 0; i < n; ++i) {
    q[i].second.first = sj[q[i].second.first];
    if (q[i].first == 1) {
      upd(q[i].second.first, q[i].second.second);
    } else if (q[i].first == 2) {
      del(q[i].second.first, q[i].second.second);
    } else {
      cout << ans(q[i].second.first, q[i].second.second) << '\n';
    }
  }
  return 0;
}
