#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const int inf = 1e9 + 10;
map<int, map<int, int>> mp;
void upd(int i, int num, int val) {
  for (; i < inf; i += i & (-i)) {
    mp[i][num] += val;
  }
}
int get(int i, int num) {
  int sum = 0;
  for (; i > 0; i -= i & (-i)) {
    if (mp[i].count(num)) sum += mp[i][num];
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, t, x;
    cin >> a >> t >> x;
    switch (a) {
      case 1:
        upd(t, x, 1);
        break;
      case 2:
        upd(t, x, -1);
        break;
      case 3:
        cout << get(t, x) << endl;
        break;
    }
  }
  return 0;
}
