#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T BM(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T mdINV(T a, T M) {
  return BM(a, M - 2, M);
}
template <class T>
inline T PW(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
string NTS(T Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
template <class T>
T stringtonumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
}
template <class T>
bool ISLEFT(T a, T b, T c) {
  if (((a.first.first - b.first.first) * (b.second.second - c.second.second) -
       (b.first.first - c.first.first) * (a.second.second - b.second.second)) <
      0.0)
    return 1;
  else
    return 0;
}
struct data {
  int info;
  int l, r;
  data() {
    info = 0;
    l = 0;
    r = 0;
  }
};
data tr[100000 * 40];
int avail = 0;
int update(int no, int s, int e, int in, int val) {
  int idx = no;
  if (!no) {
    idx = ++avail;
  }
  if (s == e) {
    tr[idx].info += val;
    return idx;
  }
  int mid = (s + e) / 2;
  if (mid >= in) {
    tr[idx].l = update(tr[idx].l, s, mid, in, val);
  } else {
    tr[idx].r = update(tr[idx].r, mid + 1, e, in, val);
  }
  tr[idx].info = (tr[tr[idx].l].info + tr[tr[idx].r].info);
  return idx;
}
int query(int idx, int s, int e, int st, int en) {
  if (idx == 0) return 0;
  if (s >= st && e <= en) return tr[idx].info;
  int mid = (s + e) / 2;
  if (mid >= en)
    return query(tr[idx].l, s, mid, st, en);
  else if (mid < st)
    return query(tr[idx].r, mid + 1, e, st, en);
  else
    return query(tr[idx].l, s, mid, st, mid) +
           query(tr[idx].r, mid + 1, e, mid + 1, en);
}
int main() {
  int n;
  scanf("%d", &n);
  map<int, int> mp;
  while (n--) {
    int first, second, z;
    scanf("%d%d%d", &first, &second, &z);
    if (first == 1) {
      mp[z] = update(mp[z], 1, 1000000007, second, 1);
    } else if (first == 2) {
      mp[z] = update(mp[z], 1, 1000000007, second, -1);
    } else {
      printf("%d\n", query(mp[z], 1, 1000000007, 1, second));
    }
  }
  return 0;
}
