#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
pair<int, int> line(int x, int y) {
  int g = gcd(x, y);
  return make_pair(x / g, y / g);
}
long long dist(long long x, long long y) { return x * x + y * y; }
map<pair<int, int>, int> M1, M2;
map<long long, set<pair<int, int> > > G;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  int cur = 0;
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      cur++;
      M1[line(x, y)]++;
      for (auto p : G[dist(x, y)]) {
        M2[line(x + p.first, y + p.second)]++;
      }
      G[dist(x, y)].insert({x, y});
    } else if (t == 2) {
      cur--;
      M1[line(x, y)]--;
      G[dist(x, y)].erase({x, y});
      for (auto p : G[dist(x, y)]) {
        M2[line(x + p.first, y + p.second)]--;
      }
    } else {
      cout << cur - 2 * M2[line(x, y)] - M1[line(x, y)] << "\n";
    }
  }
  return 0;
}
