#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
map<long long, long long> seg[4 * N];
long long n;
long long cnt = 0;
struct query {
  long long a, t, b;
};
void update(long long idx, long long val, bool check, long long v = 1,
            long long tl = 1, long long tr = n) {
  if (idx < tl || idx > tr) return;
  if (idx >= tl && idx <= tr) {
    check ? seg[v][val]++ : seg[v][val]--;
    if (tl == tr) return;
  }
  long long tm = tl + tr >> 1, lc = 2 * v, rc = 2 * v + 1;
  update(idx, val, check, lc, tl, tm);
  update(idx, val, check, rc, tm + 1, tr);
}
long long get(long long l, long long r, long long val, long long v = 1,
              long long tl = 1, long long tr = n) {
  if (l > r) return 0;
  if (l == tl && r == tr) {
    return seg[v][val];
  }
  long long tm = tl + tr >> 1, lc = 2 * v, rc = 2 * v + 1;
  return get(l, min(r, tm), val, lc, tl, tm) +
         get(max(l, tm + 1), r, val, rc, tm + 1, tr);
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  vector<query> v(n);
  vector<long long> temp;
  for (long long i = 0; i < n; i++) {
    long long a, t, b;
    cin >> a >> t >> b;
    v[i] = {a, t, b};
    temp.push_back(t);
  }
  sort(temp.begin(), temp.end());
  for (long long i = 0; i < n; i++) {
    long long a = v[i].a, t = v[i].t, b = v[i].b;
    t = lower_bound(temp.begin(), temp.end(), t) - temp.begin() + 1;
    if (a == 1) {
      update(t, b, true);
    } else if (a == 2) {
      update(t, b, false);
    } else {
      long long ans = get(1, t, b);
      cout << ans << '\n';
    }
  }
  return 0;
}
