#include <bits/stdc++.h>
const int maxed = 200000 + 10;
struct Node {
  int x, y;
};
std::vector<Node> ve[maxed];
std::vector<Node>::iterator it;
std::map<long long, int> id;
std::map<std::pair<int, int>, int> ma;
int n, id_cnt;
int gcd_(int a, int b);
int main() {
  scanf("%d", &n);
  int a, b, c, sum = 0;
  while (n--) {
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      sum += 1;
      long long w = 1LL * b * b + 1LL * c * c;
      if (!id.count(w)) id[w] = (++id_cnt);
      int wa = id[w];
      ve[wa].push_back((Node){b, c});
      int len = ve[wa].size();
      for (int i = 0; i < len; ++i) {
        int x = ve[wa][i].x + b;
        int y = ve[wa][i].y + c;
        int z = gcd_(x, y);
        if (b == ve[wa][i].x && c == ve[wa][i].y)
          ma[std::pair<int, int>(x / z, y / z)] += 1;
        else
          ma[std::pair<int, int>(x / z, y / z)] += 2;
      }
    } else if (a == 2) {
      sum -= 1;
      long long w = 1LL * b * b + 1LL * c * c;
      int wa = id[w], len = ve[wa].size();
      for (int i = 0; i < len; ++i) {
        int x = ve[wa][i].x + b;
        int y = ve[wa][i].y + c;
        int z = gcd_(x, y);
        if (ve[wa][i].x == b && ve[wa][i].y == c)
          ma[std::pair<int, int>(x / z, y / z)] -= 1;
        else
          ma[std::pair<int, int>(x / z, y / z)] -= 2;
      }
      for (it = ve[wa].begin(); it != ve[wa].end(); ++it)
        if (it->x == b && it->y == c) {
          ve[wa].erase(it);
          break;
        }
    } else {
      int z = gcd_(b, c), wa = 0;
      if (ma.count(std::pair<int, int>(b / z, c / z)))
        wa = ma[std::pair<int, int>(b / z, c / z)];
      printf("%d\n", sum - wa);
    }
  }
  return 0;
}
int gcd_(int a, int b) {
  if (!b) return a;
  return gcd_(b, a % b);
}
