#include <bits/stdc++.h>
using namespace std;
struct tree {
  struct node {
    node *l;
    node *r;
    int64_t val;
    node() : l(nullptr), r(nullptr), val(0) {}
  };
  node m_root;
  void update(node *root, int64_t tl, int64_t tr, int64_t pos, int64_t add) {
    if (pos < tl) return;
    if (tl > tr) return;
    if (tl == tr && tl == pos) {
      root->val += add;
      return;
    }
    int64_t tm = (tl + tr) / 2;
    if (pos <= tm) {
      if (!root->l) root->l = new node();
      update(root->l, tl, tm, pos, add);
    } else {
      if (!root->r) root->r = new node();
      update(root->r, tm + 1, tr, pos, add);
    }
    root->val = 0;
    if (root->l) root->val += root->l->val;
    if (root->r) root->val += root->r->val;
  }
  int64_t sum(node *root, int64_t tl, int64_t tr, int64_t l, int64_t r) {
    if (tl > tr) return 0;
    if (l > r) return 0;
    if (tl == l && tr == r) return root->val;
    int64_t tm = (tl + tr) / 2;
    int64_t ans = 0;
    if (root->l) ans += sum(root->l, tl, tm, l, min(r, tm));
    if (root->r) ans += sum(root->r, tm + 1, tr, max(tm + 1, l), r);
    return ans;
  }
};
struct type {
  tree seg;
};
int main(void) {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int64_t m = 1000 * 1000 * 1000;
  map<int, type> v;
  for (int i = 0; i < n; ++i) {
    int a, t, x;
    cin >> a >> t >> x;
    if (a == 1) {
      auto &seg = v[x].seg;
      seg.update(&seg.m_root, 1, m, t, 1);
    } else if (a == 2) {
      auto &seg = v[x].seg;
      seg.update(&seg.m_root, 1, m, t, -1);
    } else {
      auto &seg = v[x].seg;
      int64_t ans = seg.sum(&seg.m_root, 1, m, 1, t);
      cout << ans << endl;
    }
  }
  return 0;
}
