#include <bits/stdc++.h>
using namespace std;
long long int pw(long long int a, long long int b, long long int mod) {
  if (!b) return 1;
  if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
  return pw(a * a % mod, b / 2, mod) % mod;
}
const long long int N = 1e5 + 10;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
int n, fen[N], ans[N];
pair<int, pair<int, int>> Q[N];
vector<pair<int, pair<int, int>>> A[N];
vector<int> vec[2];
void Add(int x, int val) {
  for (; x < N; x += x & (-x)) fen[x] += val;
}
int Get(int ind) {
  int ans = 0;
  for (; ind > 0; ind -= ind & (-ind)) ans += fen[ind];
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> Q[i].first >> Q[i].second.first >> Q[i].second.second;
    vec[0].push_back(Q[i].second.first);
    vec[1].push_back(Q[i].second.second);
  }
  for (int j = 0; j < 2; j++) {
    sort(vec[j].begin(), vec[j].end());
    vec[j].erase(unique(vec[j].begin(), vec[j].end()), vec[j].end());
  }
  for (int i = 0; i < n; i++) {
    int x = lower_bound(vec[1].begin(), vec[1].end(), Q[i].second.second) -
            vec[1].begin();
    int t = lower_bound(vec[0].begin(), vec[0].end(), Q[i].second.first) -
            vec[0].begin();
    A[x].push_back({i, {Q[i].first, t + 1}});
  }
  for (int i = 0; i < N; i++) {
    for (auto [ind, q] : A[i]) {
      if (q.first == 1) Add(q.second, 1);
      if (q.first == 2) Add(q.second, -1);
      if (q.first == 3) ans[ind] = Get(q.second);
    }
    for (auto [ind, q] : A[i]) {
      if (q.first == 1) Add(q.second, -1);
      if (q.first == 2) Add(q.second, +1);
    }
  }
  for (int i = 0; i < n; i++) {
    if (Q[i].first != 3) continue;
    cout << ans[i] << '\n';
  }
  return 0;
}
