#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct node {
  int x, y;
  node() {}
  node(int x, int y) : x(x), y(y) {}
  node F() {
    int GCD = gcd(x, y);
    node res(x / GCD, y / GCD);
    return res;
  }
  bool operator<(const node &r) const { return x == r.x ? y < r.y : x < r.x; }
  node operator+(const node &r) const { return node(x + r.x, y + r.y).F(); }
} now;
int q;
map<long long, set<node>> exist;
map<node, int> ans;
void Run() {
  while (scanf("%d", &q) != EOF) {
    int cnt = 0;
    exist.clear();
    ans.clear();
    for (int i = 1, op; i <= q; ++i) {
      scanf("%d%d%d", &op, &now.x, &now.y);
      long long d = (long long)now.x * now.x + (long long)now.y * now.y;
      if (op == 1) {
        ++cnt;
        ++ans[now.F()];
        for (auto p : exist[d]) ans[now + p] += 2;
        exist[d].insert(now);
      } else if (op == 2) {
        --cnt;
        --ans[now.F()];
        exist[d].erase(now);
        for (auto p : exist[d]) ans[now + p] -= 2;
      } else
        printf("%d\n", cnt - ans[now.F()]);
    }
  }
}
int main() {
  Run();
  return 0;
}
