#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > M;
map<int, vector<int> > first;
int tip[1111111], t[1111111], x[1111111], n;
int get(const vector<int>& v, int x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
void add(vector<int>& first, int x, int d) {
  while (x < first.size()) {
    first[x] += d;
    x = (x | (x + 1));
  }
}
int sum(const vector<int>& first, int x) {
  int res = 0;
  while (x >= 0) {
    res += first[x];
    x = (x & (x + 1)) - 1;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &tip[i], &t[i], &x[i]);
    M[x[i]].push_back(t[i]);
  }
  for (auto& item : M) {
    int x = item.first;
    auto& v = item.second;
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    first[x].assign(v.size(), 0);
  }
  for (int i = 0; i < n; i++) {
    int p = get(M[x[i]], t[i]);
    if (tip[i] == 1) {
      add(first[x[i]], p, 1);
    } else if (tip[i] == 2) {
      add(first[x[i]], p, -1);
    } else {
      printf("%d\n", sum(first[x[i]], p));
    }
  }
  return 0;
}
