#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const long long Mod = 998244353;
const long long INF = (1LL << 60);
namespace IO {
template <typename T>
inline void read(T &x) {
  char c = getchar();
  int f = 1;
  x = 0;
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = x < y ? x : y;
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
}  // namespace IO
namespace CALC {
template <typename T>
inline void Add(T &x, T y) {
  x = (x + y) % Mod;
}
template <typename T>
inline void Sub(T &x, T y) {
  x = ((x - y) % Mod + Mod) % Mod;
}
template <typename T>
inline T pls(T x, T y) {
  return (x + y) % Mod;
}
template <typename T>
inline T slp(T x, T y) {
  return ((x - y) % Mod + Mod) % Mod;
}
inline long long qpow(long long x, long long y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x % Mod)
    if (y & 1) ret = ret * x % Mod;
  return ret;
}
}  // namespace CALC
using namespace IO;
using namespace CALC;
struct Node {
  int opt, t, x, Id;
} a[MAXN], b[MAXN];
int N;
int ans[MAXN];
bool que[MAXN];
unordered_map<int, int> Mp;
inline void CDQ(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1, L = l, R = mid + 1;
  for (int i = l; i <= r; i++) b[i] = a[i];
  Mp.clear();
  sort(b + l, b + mid + 1, [&](Node a, Node b) { return a.t < b.t; });
  sort(b + mid + 1, b + r + 1, [&](Node a, Node b) { return a.t < b.t; });
  while (L <= mid || R <= r) {
    if (R > r || (L <= mid && b[L].t <= b[R].t)) {
      if (b[L].opt == 1)
        Mp[b[L].x]++;
      else if (b[L].opt == 2)
        Mp[b[L].x]--;
      L++;
    } else {
      if (b[R].opt == 3) ans[b[R].Id] += Mp[b[R].x];
      R++;
    }
  }
  CDQ(l, mid);
  CDQ(mid + 1, r);
}
int main() {
  read(N);
  for (int i = 1; i <= N; i++) {
    read(a[i].opt);
    read(a[i].t);
    read(a[i].x);
    a[i].Id = i;
    if (a[i].opt == 3) que[i] = true;
  }
  CDQ(1, N);
  for (int i = 1; i <= N; i++)
    if (que[i]) printf("%d\n", ans[i]);
  return 0;
}
