#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = (1 << 20);
unordered_map<long long, vector<pair<int, int> > > mp;
unordered_map<long long, int> ans;
int gcd(int a, int b);
long long getHash(int a, int b) {
  static const long long c = 1e6;
  long long gc = gcd(a, b);
  a /= gc;
  b /= gc;
  return a * c + b;
}
long long getSq(int a, int b) { return a * 1ll * a + b * 1ll * b; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  int cntPoints = 0;
  for (int qw = 0; qw < q; ++qw) {
    int t, first, second;
    cin >> t >> first >> second;
    if (t == 1) {
      cntPoints++;
      for (auto it : mp[getSq(first, second)]) {
        ans[getHash(first + it.first, second + it.second)] += 2;
      }
      mp[getSq(first, second)].push_back({first, second});
      ans[getHash(first, second)]++;
    } else if (t == 2) {
      cntPoints--;
      pair<int, int> curPoint = {first, second};
      vector<pair<int, int> > tmp = mp[getSq(first, second)];
      for (int i = 0, j = 0; i < (int)tmp.size() - 1; ++i, ++j) {
        if (tmp[j] == curPoint) j++;
        tmp[i] = tmp[j];
      }
      tmp.pop_back();
      mp[getSq(first, second)] = tmp;
      for (auto it : mp[getSq(first, second)]) {
        ans[getHash(first + it.first, second + it.second)] -= 2;
      }
      ans[getHash(first, second)]--;
    } else {
      long long curAns = cntPoints - (int)ans[getHash(first, second)];
      cout << curAns << "\n";
    }
  }
  return 0;
}
