#include <bits/stdc++.h>
using namespace std;
struct IO {
  inline int read() {
    int sum = 0, ff = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
      if (ch == '-') ff = -1;
      ch = getchar();
    }
    while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
    return sum * ff;
  }
  inline void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + 48);
  }
  inline void writeln(int x) {
    write(x);
    putchar('\n');
  }
} fast;
const int maxn = 2333333;
map<int, int> c[maxn];
int n, m, ans, cnt, res;
int bo[maxn], x[maxn];
int y[maxn], z[maxn], Bo[maxn];
inline void add(int x, int bl, int val) {
  while (x <= 1e9) {
    c[bl][x] += val;
    x += x & (-x);
  }
}
inline int query(int x, int bl) {
  int ret = 0;
  while (x) {
    ret += c[bl][x];
    x -= x & (-x);
  }
  return ret;
}
int main() {
  n = fast.read();
  for (int i = 1; i <= n; i++) {
    x[i] = fast.read();
    y[i] = fast.read();
    z[i] = fast.read();
    Bo[i] = z[i];
  }
  sort(Bo + 1, Bo + n + 1);
  int s = unique(Bo + 1, Bo + n + 1) - Bo - 1;
  for (int i = 1; i <= n; i++)
    z[i] = lower_bound(Bo + 1, Bo + s + 1, z[i]) - Bo;
  for (int i = 1; i <= n; i++) {
    if (x[i] == 1) add(y[i], z[i], 1);
    if (x[i] == 2) add(y[i], z[i], -1);
    if (x[i] == 3) fast.writeln(query(y[i], z[i]));
  }
  return 0;
}
