#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1061109567;
const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
map<int, int> mp[100005], vis;
int tot;
int lowbit(int x) { return x & (-x); }
void update(int t, int x, int val) {
  for (int i = t; i <= 1e9 + 2; i += lowbit(i)) {
    mp[x][i] += val;
  }
}
int query(int t, int x) {
  int ret = 0;
  for (int i = t; i > 0; i -= lowbit(i)) {
    ret += mp[x][i];
  }
  return ret;
}
int main() {
  int n, sign, t, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &sign, &t, &x);
    if (!vis[x]) {
      vis[x] = ++tot;
    }
    if (sign == 1) {
      update(t, vis[x], 1);
    } else if (sign == 2) {
      update(t, vis[x], -1);
    } else {
      printf("%d\n", query(t, vis[x]));
    }
  }
  return 0;
}
