#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ld = long double;
using ulli = unsigned long long;
using ii = pair<int, int>;
void deb(istream_iterator<string> it) { it = it; }
template <typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  deb(++it, args...);
}
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, rge<T> d) {
  os << "[";
  for (auto it = d.b; it != d.e; it++) os << (it == d.b ? "" : ", ") << *it;
  return os << "]";
}
const lli mod = 1e7 + 7;
const lli N = 2 * 1e5 + 5;
const lli inf = 1e6;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const int DX[4] = {1, 1, -1, -1}, DY[4] = {1, -1, 1, -1};
const ld eps = 1e-9;
struct segtree {
  int l, r;
  lli sum;
  segtree *left, *right;
  segtree(int l, int r, lli v = 0) : l(l), r(r), sum(v), left(0), right(0) {}
  void pull() {
    sum = 0;
    if (left) sum += left->sum;
    if (right) sum += right->sum;
  }
  void update(int p, lli v) {
    if (l == r) {
      sum += v;
      return;
    }
    int m = (l + r) / 2;
    if (p <= m) {
      if (!left) left = new segtree(l, m);
      left->update(p, v);
    } else {
      if (!right) right = new segtree(m + 1, r);
      right->update(p, v);
    }
    pull();
  }
  lli qsum(int ll, int rr) {
    if (rr < l || r < ll) return 0;
    if (ll <= l && r <= rr) return sum;
    int m = (l + r) / 2;
    lli sumx = 0;
    if (left) sumx += left->qsum(ll, rr);
    if (right) sumx += right->qsum(ll, rr);
    return sumx;
  }
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr),
      cout.precision(15);
  ;
  map<int, segtree *> mp;
  int type, where, k, tc;
  cin >> tc;
  while (tc--) {
    cin >> type >> where >> k;
    if (!mp.count(k)) mp[k] = new segtree(1, 1e9);
    if (type == 1) {
      mp[k]->update(where, +1);
    }
    if (type == 2) {
      mp[k]->update(where, -1);
    }
    if (type == 3) {
      cout << mp[k]->qsum(1, where) << '\n';
    }
  }
  return 0;
}
