#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:300000000")
using namespace std;
struct node {
  node *R = NULL, *L = NULL;
  int cou = 0;
  bool need = false;
  int to_push = 0;
};
void push(node* this_n) {
  if (this_n->need) {
    this_n->need = false;
    if (this_n->L == NULL) {
      this_n->L = new node;
      this_n->L->need = true;
      this_n->L->cou += this_n->to_push;
      this_n->L->to_push += this_n->to_push;
    } else {
      this_n->L->need = true;
      this_n->L->cou += this_n->to_push;
      this_n->L->to_push += this_n->to_push;
    }
    if (this_n->R == NULL) {
      this_n->R = new node;
      this_n->R->need = true;
      this_n->R->cou += this_n->to_push;
      this_n->R->to_push += this_n->to_push;
    } else {
      this_n->R->need = true;
      this_n->R->cou += this_n->to_push;
      this_n->R->to_push += this_n->to_push;
    }
    this_n->to_push = 0;
  }
  if (this_n->L == NULL) this_n->L = new node;
  if (this_n->R == NULL) this_n->R = new node;
}
void update(node* this_n, int tl, int tr, int l, int r, int value) {
  if (l > r) return;
  if (tl == l && tr == r) {
    this_n->cou += value;
    this_n->to_push += value;
    this_n->need = true;
    return;
  }
  push(this_n);
  int tm = (tl + tr) / 2;
  update(this_n->L, tl, tm, l, min(tm, r), value);
  update(this_n->R, tm + 1, tr, max(l, tm + 1), r, value);
}
int get(node* this_n, int tl, int tr, int pos) {
  if (tl == tr) return this_n->cou;
  push(this_n);
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    return get(this_n->L, tl, tm, pos);
  else
    return get(this_n->R, tm + 1, tr, pos);
}
int main() {
  map<long long, node*> mass;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int type, value;
    int time;
    scanf("%d%d%d", &type, &time, &value);
    if (type == 1) {
      if (!mass.count(value)) mass[value] = new node();
      update(mass[value], 0, 1e9, time - 1, 1e9, 1);
    }
    if (type == 2) {
      update(mass[value], 0, 1e9, time - 1, 1e9, -1);
    }
    if (type == 3) {
      if (!mass.count(value)) mass[value] = new node();
      printf("%d\n", get(mass[value], 0, 1e9, time - 1));
    }
  }
  return 0;
}
