#include <bits/stdc++.h>
using namespace std;
struct node {
  long long a, t, q;
};
struct fenwick_tree {
  long long size, log_size;
  vector<long long> tree;
  fenwick_tree(long long _size)
      : size(_size),
        log_size((long long)(log2(_size) + 1.0L)),
        tree(_size + 5) {}
  void update(long long p, long long x) {
    while (p <= size) {
      tree[p] += x;
      p += p & (-p);
    }
  }
  long long prefix_sum(long long p) {
    long long r = 0;
    while (p) {
      r += tree[p];
      p -= p & (-p);
    }
    return r;
  }
  void resetN(long long N) {
    size = N;
    for (long long i = 1; i <= N; i++) tree[i] = 0;
  }
};
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  fenwick_tree bit(100005);
  long long n;
  cin >> n;
  map<long long, vector<node>> mp;
  for (long long i = 0; i < n; i++) {
    long long val;
    node temp;
    cin >> temp.a >> temp.t >> val;
    temp.q = i;
    mp[val].push_back(temp);
  }
  set<pair<long long, long long>> s;
  for (auto &vec : mp) {
    set<long long> time;
    for (auto &k : vec.second) time.insert(k.t);
    map<long long, long long> tmp;
    long long pos = 1;
    for (auto &k : time) tmp[k] = pos++;
    for (auto &k : vec.second) k.t = tmp[k.t];
    bit.resetN(pos + 1);
    for (auto &k : vec.second) {
      if (k.a == 1) {
        bit.update(k.t, 1);
      } else if (k.a == 2) {
        bit.update(k.t, -1);
      } else {
        s.insert({k.q, bit.prefix_sum(k.t)});
      }
    }
  }
  for (auto &k : s) cout << k.second << "\n";
}
