#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
inline void add(long long &a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
template <typename T>
inline T const &MAX(T const &a, T const &b) {
  return a > b ? a : b;
}
template <typename T>
inline T const &MIN(T const &a, T const &b) {
  return a < b ? a : b;
}
inline long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 1000000007;
    a = a * a % 1000000007, b >>= 1;
  }
  return ans;
}
inline long long qp(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c, b >>= 1;
  }
  return ans;
}
using namespace std;
const unsigned long long ba = 233;
const double eps = 1e-5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 100000 + 10, maxn = 1000000 + 10, inf = 0x3f3f3f3f;
struct bit {
  map<int, int> s[N];
  void update(int op, int i, int x) {
    for (; i < N; i += i & (-i)) {
      if (op == 1)
        s[i][x]++;
      else {
        s[i][x]--;
        if (s[i][x] == 0) s[i].erase(x);
      }
    }
  }
  int query(int i, int x) {
    int ans = 0;
    for (; i; i -= i & (-i))
      if (s[i].find(x) != s[i].end()) ans += s[i][x];
    return ans;
  }
} b;
tuple<int, int, int> a[N];
int c[N], cnt;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    a[i] = make_tuple(x, y, z);
    c[cnt++] = y;
  }
  sort(c, c + cnt);
  cnt = unique(c, c + cnt) - c;
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    tie(x, y, z) = a[i];
    y = lower_bound(c, c + cnt, y) - c + 1;
    if (x != 3)
      b.update(x, y, z);
    else
      printf("%d\n", b.query(y, z));
  }
  return 0;
}
