#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, c = 0;
  cin >> n >> m;
  for (int a = 0; a * a <= n && a <= m; ++a) {
    b = n - a * a;
    if (a + b * b == m) {
      c++;
    }
  }
  cout << c;
  return 0;
}
