#include <bits/stdc++.h>
inline void read_int(int &var) {
  var = 0;
  bool sign = 0;
  char c;
  while ((c = getchar()) <= 32)
    ;
  if (c == '-') sign = 1, c = getchar();
  while ('0' <= c and c <= '9')
    var = (var << 3) + (var << 1) + (c - '0'), c = getchar();
  if (sign) var ^= -1, var += 1;
}
inline void read_int(int &v1, int &v2) {
  read_int(v1);
  read_int(v2);
}
inline void read_int(int &v1, int &v2, int &v3) {
  read_int(v1);
  read_int(v2, v3);
}
const int buffer_size = 20;
char buffer[buffer_size];
inline void write_int(int var) {
  if (not var) {
    putchar('0');
    putchar(' ');
    return;
  }
  if (std::signbit(var)) putchar('-'), var -= 1, var ^= -1;
  size_t sign_digit = 0;
  while (var) {
    buffer[sign_digit++] = '0' + var % 10;
    var = (var >> 1) / 5;
  }
  while (sign_digit) putchar(buffer[--sign_digit]);
  putchar(' ');
}
const int INF = 1e+9 + 1;
using namespace std;
int main() {
  int n, a, t, x;
  read_int(n);
  vector<tuple<int, int> > act[2];
  while (n--) {
    read_int(a, t, x);
    const tuple<int, int> record = make_tuple(x, t);
    if ((a--) ^ 3) {
      act[a].push_back(record);
      size_t i;
      for (i = act[a].size() - 1; i > 0 and act[a][i - 1] > record; --i)
        act[a][i] = act[a][i - 1];
      act[a][i] = record;
    } else {
      write_int(int(upper_bound((act[0]).begin(), (act[0]).end(), record) -
                    lower_bound((act[0]).begin(), (act[0]).end(),
                                make_tuple(x - 1, INF))) -
                int(upper_bound((act[1]).begin(), (act[1]).end(), record) -
                    lower_bound((act[1]).begin(), (act[1]).end(),
                                make_tuple(x - 1, INF))));
      putchar('\n');
    }
  }
  return 0;
}
