#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 28;
const long long LINF = 1ll << 61;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c != ' ' && c != '\n') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
inline char mygetchar() {
  register char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
int n;
map<int, int> hs;
vector<int> ti;
int hstot, qtot;
vector<pair<int, int> > v[100111];
int ans[100111];
struct BIT {
  int a[100111];
  int tag[100111];
  int cur;
  BIT() {
    memset(a, 0, sizeof(a));
    memset(tag, 0, sizeof(tag));
    cur = 0;
  }
  void add(int i, int x) {
    while (i <= 100005) {
      if (tag[i] != cur) tag[i] = cur, a[i] = 0;
      a[i] += x;
      i += i & (-i);
    }
  }
  int sum(int i) {
    int ans = 0;
    while (i > 0) {
      if (tag[i] != cur) tag[i] = cur, a[i] = 0;
      ans += a[i];
      i -= i & (-i);
    }
    return ans;
  }
  void changetag(int x) { cur = x; }
} bit;
int main() {
  n = getnum();
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    x = getnum(), y = getnum(), z = getnum();
    int &val = hs[z];
    if (val == 0) val = ++hstot;
    ti.push_back(y);
    if (x == 3)
      v[val].push_back(make_pair(y, ++qtot));
    else if (x == 1)
      v[val].push_back(make_pair(y, -1));
    else
      v[val].push_back(make_pair(y, -2));
  }
  sort(ti.begin(), ti.end());
  ti.erase(unique(ti.begin(), ti.end()), ti.end());
  for (int i = 1; i <= hstot; i++) {
    bit.changetag(i);
    for (int j = 0; j < v[i].size(); j++) {
      v[i][j].first =
          lower_bound(ti.begin(), ti.end(), v[i][j].first) - ti.begin() + 1;
      if (v[i][j].second > 0) {
        ans[v[i][j].second] = bit.sum(v[i][j].first);
      } else {
        bit.add(v[i][j].first, v[i][j].second == -1 ? 1 : -1);
      }
    }
  }
  for (int i = 1; i <= qtot; i++) putnum(ans[i]), putendl();
  return 0;
}
