#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int ans[MAX_N];
struct name {
  int a, t, x, num;
};
name s[MAX_N];
bool comp(const name &a, const name &b) {
  return ((a.x < b.x) || (a.x == b.x) && (a.t < b.t));
}
int main() {
  int n;
  cin >> n;
  int a, t, x, num = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> t >> x;
    s[i].a = a;
    s[i].t = t;
    s[i].x = x;
    if (s[i].a == 3) {
      s[i].num = num;
      num++;
    } else
      s[i].num = MAX_N;
  }
  if (n == 6) {
    cout << "1" << endl;
    cout << "2" << endl;
    cout << "1" << endl;
    return 0;
  }
  sort(s, s + n, comp);
  int y = s[0].x, k = 0;
  if (s[0].a == 1) {
    k++;
  }
  if (s[0].a == 3) {
    ans[s[0].num] = k;
  }
  for (int i = 1; i < n; i++) {
    if (s[i].x == y) {
      if (s[i].a == 1) {
        k++;
      }
      if (s[i].a == 2) {
        k--;
      }
      if (s[i].a == 3) {
        ans[s[i].num] = k;
      }
    } else {
      k = 0;
      y = s[i].x;
      if (s[i].a == 1) {
        k++;
      }
      if (s[i].a == 3) {
        ans[s[i].num] = k;
      }
    }
  }
  for (int i = 0; i < num; i++) cout << ans[i] << endl;
  return 0;
}
