#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int maxn = 1 << 17;
int I, Q;
unordered_map<int, int> F;
struct ST {
  ST(int a = 0, int b = INF) : a(a), b(b), s(0), child{nullptr, nullptr} {
    m = (a + b) >> 1;
  }
  ST* gc(int n) {
    if (child[n]) return child[n];
    return child[n] = new ST(n ? m : a, n ? b : m);
  }
  void set(int x, int v) {
    s += v;
    if (a + 1 == b) return;
    if (x < m)
      gc(0)->set(x, v);
    else
      gc(1)->set(x, v);
  }
  int get(int x) {
    if (x < a) return 0;
    if (b <= x + 1) return s;
    return gc(0)->get(x) + gc(1)->get(x);
  }
  int a, b, m, s;
  ST* child[2];
};
int getIndex(int x) {
  if (F.count(x)) return F[x];
  return F[x] = I++;
}
ST T[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int a, b, c;
  cin >> Q;
  F.reserve(Q);
  for (int i = 0; i < int(Q); ++i) {
    cin >> a >> b >> c;
    c = getIndex(c);
    if (a == 1)
      T[c].set(b, +1);
    else if (a == 2)
      T[c].set(b, -1);
    else
      cout << T[c].get(b) << endl;
  }
  return 0;
}
