#include <bits/stdc++.h>
using namespace std;
unordered_map<int, unordered_map<int, int> > m1;
void update(int time, int index, int value) {
  while (time <= 300005) {
    int ind = index;
    while (ind <= 300005) {
      m1[time][ind] += value;
      ind += (ind & -ind);
    }
    time += (time & -time);
  }
}
int sum(int time, int index) {
  int s = 0;
  while (time > 0) {
    int ind = index;
    while (ind > 0) {
      s += m1[time][ind];
      ind -= (ind & -ind);
    }
    time -= (time & -time);
  }
  return s;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, pair<int, int> > > v1;
  vector<int> v2;
  for (int i = 0; i < n; i++) {
    int x, y, z;
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &z);
    v1.push_back(make_pair(x, make_pair(y, z)));
    v2.push_back(y);
    v2.push_back(z);
  }
  sort(v2.begin(), v2.end());
  int ctr = 1;
  unordered_map<int, int> m2;
  for (int i = 0; i < v2.size(); i++) {
    if (m2[v2[i]] == 0) {
      m2[v2[i]] = ctr;
      ctr++;
    }
  }
  for (int i = 0; i < n; i++) {
    v1[i].second.first = m2[v1[i].second.first];
    v1[i].second.second = m2[v1[i].second.second];
  }
  for (int i = 0; i < n; i++) {
    if (v1[i].first == 1) {
      update(v1[i].second.first, v1[i].second.second, 1);
    } else if (v1[i].first == 2) {
      update(v1[i].second.first, v1[i].second.second, -1);
    } else if (v1[i].first == 3) {
      printf("%d\n", sum(v1[i].second.first, v1[i].second.second) -
                         sum(v1[i].second.first, v1[i].second.second - 1));
    }
  }
}
