#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
class LIGUE_PARA_991178584_paraduvidas {
 private:
  map<int, map<int, int> > BIT;

 public:
  int rsq(int t, int k) {
    int sum = 0;
    for (; t; t -= (t & (-t))) sum += BIT[t][k];
    return sum;
  }
  void adjust(int t, int k, int v) {
    for (; t < 1e9 + 1; t += (t & (-t))) BIT[t][k] += v;
  }
};
int main() {
  int n;
  scanf("%d", &n);
  LIGUE_PARA_991178584_paraduvidas xablauzera;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      xablauzera.adjust(b, c, 1);
    }
    if (a == 2) {
      xablauzera.adjust(b, c, -1);
    }
    if (a == 3) {
      printf("%d\n", xablauzera.rsq(b, c));
    }
  }
  return 0;
}
