#include <bits/stdc++.h>
using namespace std;
long long int N;
long long int val[200003][3];
unordered_map<long long int, unordered_map<long long int, long long int> > mp;
long long int getNow(long long int in, long long int val) {
  long long int res = 0;
  while (in > 0) {
    if (mp[val].find(in) != mp[val].end()) res += mp[val][in];
    in -= in & (-in);
  }
  return res;
}
void addToMap(long long int in, long long int val, long long int c) {
  while (in <= 1073741824) {
    if (mp[val].find(in) == mp[val].end()) {
      mp[val][in] = c;
    } else {
      mp[val][in] += c;
    }
    in += in & (-in);
  }
}
int main(int argc, char const *argv[]) {
  scanf(" %lld", &N);
  long long int val, time, type;
  for (long long int i = (0); i < (long long int)(N); ++i) {
    scanf(" %lld %lld %lld", &type, &time, &val);
    switch (type) {
      case 1:
        addToMap(time, val, 1);
        break;
      case 2:
        addToMap(time, val, -1);
        break;
      case 3:
        printf("%lld\n", getNow(time, val));
        break;
    }
  }
  return 0;
}
