#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;
template <typename T>
void check(T& a, const T& b) {
  if (a >= b) {
    a %= b;
  }
}
template <typename T>
T gcd(T u, T v) {
  if (u == v) return u;
  if (u == 0) return v;
  if (v == 0) return u;
  if (~u & 1) {
    if (v & 1)
      return gcd(u >> 1, v);
    else
      return gcd(u >> 1, v >> 1) << 1;
  }
  if (~v & 1) return gcd(u, v >> 1);
  if (u > v) return gcd((u - v) >> 1, v);
  return gcd((v - u) >> 1, u);
}
LL mulmod(LL a, LL b, const LL& m) {
  LL q = (LL)(((LD)a * (LD)b) / (LD)m);
  LL r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T, typename S>
T expo(T e, S n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T powerL(T e, T n, const T& m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mulmod(x, p, m);
    p = mulmod(p, p, m);
    n >>= 1;
  }
  return x;
}
const int N = (int)2e5 + 10;
int n;
vector<vi> q;
map<int, int> m, bit[N];
void add(int i, int val, int add) {
  for (; i <= N; i += (i & (-i))) {
    bit[val][i] += add;
  }
}
int query(int i, int val) {
  int ans = 0;
  for (; i > 1; i -= (i & (-i))) {
    ans += bit[val][i];
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cerr.tie(NULL);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    q.push_back({a, b, c});
    m[b] = m[c] = 1;
  }
  int range = 1;
  for (auto& i : m) {
    i.second = (range++);
  }
  cerr << "here" << '\n';
  for (int i = 0; i < n; i++) {
    int type = q[i][0], b = m[q[i][1]], c = m[q[i][2]];
    cerr << type << "\n";
    if (type == 1) {
      add(b, c, 1);
    } else if (type == 2) {
      add(b, c, -1);
    } else {
      cout << query(b, c) << '\n';
    }
  }
  return 0;
}
