#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;
map<int, unordered_map<int, int>> BIT;
void update(int t, int delta, int ind) {
  while (ind <= 1e9 + 5) {
    if (t == 1)
      BIT[ind][delta]++;
    else
      BIT[ind][delta]--;
    ind += ind & -ind;
  }
}
int sum(int ind, int n) {
  int ans = 0;
  while (ind) {
    if (BIT[ind][n]) ans += BIT[ind][n];
    ind -= ind & -ind;
  }
  return ans;
}
void solve() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, t, x;
    cin >> a >> t >> x;
    if (a != 3) {
      update(a, x, t);
    } else {
      cout << sum(t, x) << "\n";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
