#include <bits/stdc++.h>
using namespace std;
int b[200050];
void update(int p, int v) {
  while (p < 200050) {
    b[p] += v;
    p += (p & -p);
  }
}
int query(int p) {
  int s = 0;
  while (p > 0) {
    s += b[p];
    p -= (p & -p);
  }
  return s;
}
signed main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, pair<int, int> > > v(n);
  map<int, int> m;
  map<int, int> mm;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &v[i].first, &v[i].second.first, &v[i].second.second);
    m[v[i].second.second] = 1;
    mm[v[i].second.first] = 1;
  }
  int ca = 1;
  int cb = 1;
  for (map<int, int>::iterator it = m.begin(); it != m.end(); it++)
    it->second = ca++;
  for (map<int, int>::iterator it = mm.begin(); it != mm.end(); it++)
    it->second = cb++;
  for (int i = 0; i < n; i++) {
    v[i].second.second = m[v[i].second.second];
    v[i].second.first = mm[v[i].second.first];
  }
  int x, y, z;
  vector<vector<pair<int, pair<int, int> > > > q(ca + 5);
  for (int i = 0; i < n; i++) {
    q[v[i].second.second].push_back({v[i].first, {v[i].second.first, i}});
  }
  int res[n];
  memset(res, -1, sizeof(res));
  for (int i = 0; i < ca; i++) {
    for (size_t j = 0; j < q[i].size(); j++) {
      x = q[i][j].first;
      y = q[i][j].second.first;
      z = q[i][j].second.second;
      if (x == 1)
        update(y, 1);
      else if (x == 2)
        update(y, -1);
      else
        res[z] = query(y);
    }
    for (size_t j = 0; j < q[i].size(); j++) {
      x = q[i][j].first;
      y = q[i][j].second.first;
      if (x == 1)
        update(y, -1);
      else if (x == 2)
        update(y, 1);
    }
  }
  for (int i = 0; i < n; i++) {
    if (res[i] != -1) printf("%d\n", res[i]);
  }
  return 0;
}
