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