#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};
tuple<int, int, int, int> query[100000];
int ans[100000];
map<int, vector<tuple<int, int, int> > > M;
int cc;
void upd(int i, vector<int>& tree, int k) {
  int n = tree.size();
  while (i < n) {
    tree[i] += k;
    i += (i & -i);
  }
}
int sum(int i, vector<int>& tree) {
  int c = 0;
  while (i > 0) {
    c += tree[i];
    i -= (i & -i);
  }
  return c;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int(i) = (0); (i) <= (n - 1); (i) += (1)) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (x == 3)
      M[z].push_back(tuple<int, int, int>(x, y, cc++));
    else
      M[z].push_back(tuple<int, int, int>(x, y, -1));
  }
  for (auto it = M.begin(); it != M.end(); it++) {
    vector<tuple<int, int, int> > v = it->second;
    int N = v.size();
    vector<int> vv;
    for (int(i) = (0); (i) <= (N - 1); (i) += (1)) vv.push_back(get<1>(v[i]));
    sort(vv.begin(), vv.end());
    vv.resize(unique(vv.begin(), vv.end()) - vv.begin());
    for (int(i) = (0); (i) <= (N - 1); (i) += (1))
      get<1>(v[i]) =
          lower_bound(vv.begin(), vv.end(), get<1>(v[i])) - vv.begin();
    vector<int> tree(N + 5, 0);
    for (int(i) = (0); (i) <= (N - 1); (i) += (1)) {
      int x, y, z;
      tie(x, y, z) = v[i];
      if (x == 1)
        upd(y + 1, tree, 1);
      else if (x == 2)
        upd(y + 1, tree, -1);
      else
        ans[z] = sum(y + 1, tree);
    }
  }
  for (int(i) = (0); (i) <= (cc - 1); (i) += (1)) printf("%d\n", ans[i]);
}
