#include <bits/stdc++.h>
using namespace std;
unordered_map<int, unordered_map<int, int>> mp;
const int mxn = 1e9;
int q;
void add(int idx, int num, int val) {
  while (idx <= mxn) {
    mp[idx][num] += val;
    idx += (idx & -idx);
  }
}
long long get(int b, int c) {
  long long ret = 0;
  while (b > 0) {
    ret += mp[b][c];
    b -= (b & -b);
  }
  return ret;
}
int main() {
  cin >> q;
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1) {
      add(b, c, 1);
    } else if (a == 2) {
      add(b, c, -1);
    } else {
      cout << get(b, c) << endl;
    }
  }
  return 0;
}
