#include <bits/stdc++.h>
using namespace std;
map<int, int> bit[100005];
vector<int> ts;
struct Node {
  int op, t, x;
} q[100005];
void insert(int times, int val) {
  for (; times <= ts.size(); times += times & -times) {
    bit[times][val]++;
  }
}
void erase(int times, int val) {
  for (; times <= ts.size(); times += times & -times) {
    bit[times][val]--;
  }
}
int query(int times, int val) {
  int sum = 0;
  for (; times; times -= times & -times) sum += bit[times][val];
  return sum;
}
int main() {
  int Q;
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++) {
    scanf("%d%d%d", &q[i].op, &q[i].t, &q[i].x);
    ts.push_back(q[i].t);
  }
  sort(ts.begin(), ts.end());
  for (int i = 0; i < Q; i++) {
    int t = lower_bound(ts.begin(), ts.end(), q[i].t) - ts.begin() + 1;
    int x = q[i].x;
    if (q[i].op == 1) {
      insert(t, x);
    } else if (q[i].op == 2) {
      erase(t, x);
    } else {
      printf("%d\n", query(t, x));
    }
  }
  return 0;
}
