#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> m[111111];
map<int, int> vis;
void update(int pos, int x, int v) {
  while (x < 1e9 + 1) {
    m[pos][x] += v;
    x += (x & (-x));
  }
}
int sum(int pos, int x) {
  int ans = 0;
  while (x) {
    ans += m[pos][x];
    x -= (x & (-x));
  }
  return ans;
}
int main() {
  while (~scanf("%d", &n)) {
    int cnt = 0;
    vis.clear();
    while (n--) {
      int type, t, x;
      scanf("%d%d%d", &type, &t, &x);
      if (type == 1 && !vis[x]) vis[x] = ++cnt, m[cnt].clear();
      if (type == 1)
        update(vis[x], t, 1);
      else if (type == 2)
        update(vis[x], t, -1);
      else
        printf("%d\n", sum(vis[x], t));
    }
  }
  return 0;
}
