#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30);
int n, m, ans = 0;
int solve() {
  cin >> n >> m;
  for (int a = 0; a <= max(n, m); a++)
    for (int b = 0; b <= max(n, m); b++) {
      if (((a) * (a)) + b == n && a + ((b) * (b)) == m) ans++;
    }
  cout << ans;
  return 0;
}
int main() {
  solve();
  return 0;
}
