#include <bits/stdc++.h>
using namespace std;
class RSQ {
 private:
  map<pair<int, int>, int> st;
  int n;
  int left(int pp) { return pp << 1; }
  int right(int pp) { return (pp << 1) + 1; }
  void buildd() {}
  long long int queryy(int pp, int l, int r, int i, int j, int idx) {
    if (i > r or j < l)
      return 0;
    else if (l >= i and j >= r) {
      return st[make_pair(idx, pp)];
    } else {
      long long int aux1 = queryy(left(pp), l, (l + r) / 2, i, j, idx);
      long long int aux2 = queryy(right(pp), (l + r) / 2 + 1, r, i, j, idx);
      return aux1 + aux2;
    }
  }
  void updatee(int pp, int l, int r, int d, int val, int idx) {
    if (d < l or d > r) return;
    if (l == r and l == d) {
      st[make_pair(idx, pp)] += val;
      return;
    } else {
      int mid = (l + r) / 2;
      if (d <= mid)
        updatee(left(pp), l, (l + r) / 2, d, val, idx);
      else
        updatee(right(pp), (l + r) / 2 + 1, r, d, val, idx);
      st[make_pair(idx, pp)] =
          st[make_pair(idx, left(pp))] + st[make_pair(idx, right(pp))];
    }
  }

 public:
  RSQ(int n) { buildd(); }
  int query(int i, int j, int tam, int idx) {
    return queryy(1, 1, tam, i, j, idx);
  }
  void update(int d, int val, int tam, int idx) {
    updatee(1, 1, tam, d, val, idx);
  }
};
int main() {
  int n;
  scanf("%d", &n);
  RSQ seg(100005);
  for (int i = 0; i < n; i++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int time, val;
      scanf("%d %d", &time, &val);
      seg.update(time, 1, 1000000005, val);
    } else if (type == 2) {
      int time, val;
      scanf("%d %d", &time, &val);
      seg.update(time, -1, 1000000005, val);
    } else {
      int time, val;
      scanf("%d %d", &time, &val);
      printf("%d\n", seg.query(1, time, 1000000005, val));
    }
  }
  return 0;
}
