#include <bits/stdc++.h>
using namespace std;
const int N = 121090;
const long long MOD = 1000000007LL;
const int fx[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
double pi = acos(-1.0);
void gcd(long long a, long long b, long long &d, long long &x, long long &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long inv(long long a, long long n) {
  long long d, x, y;
  gcd(a, n, d, x, y);
  return (x + n) % n;
}
int n, r;
int a[N], b[N], c[N], d[N], e[N], f[N];
map<int, int> mp;
queue<int> Q;
inline bool cmp(int x, int y) { return b[x] < b[y]; }
void work(int ll, int rr) {
  if (ll == rr) return;
  int mid = (ll + rr) >> 1;
  work(ll, mid);
  work(mid + 1, rr);
  int temp = ll, i = ll, j = mid + 1;
  for (; i <= mid && j <= rr;) {
    if (b[e[i]] < b[e[j]])
      f[temp++] = e[i++];
    else
      f[temp++] = e[j++];
  }
  while (i <= mid) f[temp++] = e[i++];
  while (j <= rr) f[temp++] = e[j++];
  for (i = ll; i <= rr; ++i) {
    e[i] = f[i];
    f[i] = 0;
  }
  for (i = ll; i <= rr; ++i) {
    int x = e[i];
    if (x <= mid) {
      if (a[x] == 1)
        ++f[c[x]];
      else if (a[x] == 2)
        --f[c[x]];
    } else if (a[x] == 3)
      d[x] += f[c[x]];
  }
  for (i = ll; i <= rr; ++i) {
    int x = e[i];
    if (x <= mid) {
      if (a[x] == 1)
        --f[c[x]];
      else if (a[x] == 2)
        ++f[c[x]];
    }
  }
}
int main() {
  int cases = 1;
  double ans = 0;
  for (int iii = 1; iii <= cases; ++iii) {
    scanf("%d", &n);
    int tot = 0;
    for (int i = 0; i < n; ++i) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      if (!mp[z]) mp[z] = ++tot;
      z = mp[z];
      a[i] = x;
      b[i] = y;
      c[i] = z;
    }
    memset(d, 0, sizeof(d));
    for (int i = 0; i < n; ++i) e[i] = i;
    work(0, n - 1);
    for (int i = 0; i < n; ++i)
      if (a[i] == 3) printf("%d\n", d[i]);
  }
}
