#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m, a, b, c, d, h, x = 0, y = 1e18 + 1, count = 0, i, j, k,
                                     sum = 0, ans = 0, l, r;
  cin >> a >> b;
  vector<long long int> v(n);
  for (i = 0; i < 100000; i++) {
    if (i * i > a) break;
    if (i + (a - (i * i)) * (a - (i * i)) == b) count++;
  }
  cout << count << "\n";
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fast();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
