#include <bits/stdc++.h>
using namespace std;
struct node {
  long long l;
  long long r;
  long long s;
  node* ln;
  node* rn;
  void change(long long n, long long k) {
    if (l == r)
      s += k;
    else {
      if (n <= (l + r) / 2) {
        if (ln == 0) {
          ln = new node;
          *ln = {l, (l + r) / 2, 0};
        }
        ln->change(n, k);
      } else {
        if (rn == 0) {
          rn = new node;
          *rn = {(l + r) / 2 + 1, r, 0};
        }
        rn->change(n, k);
      }
      s = 0;
      if (ln != 0) s += ln->s;
      if (rn != 0) s += rn->s;
    }
  }
  long long query(long long a, long long b) {
    if (a == l && b == r) return s;
    if (b < l || a > r) return 0;
    long long v = 0;
    if (ln != 0) v += ln->query(a, min(b, (l + r) / 2));
    if (rn != 0) v += rn->query(max(a, (l + r) / 2 + 1), b);
    return v;
  }
};
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  unordered_map<int, node> m;
  for (int i = 0; i < n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (!m.count(c)) m[c] = {1, 1 << 30, 0};
    if (a == 1)
      m[c].change(b, 1);
    else if (a == 2)
      m[c].change(b, -1);
    else
      cout << m[c].query(1, b) << "\n";
  }
}
