#include <bits/stdc++.h>
using namespace std;
int main() {
  double n, m, x, y;
  cin >> n >> m;
  int counter = 0;
  for (double i = 0; i <= sqrt(n); i++) {
    for (double j = 0; j <= sqrt(m); j++) {
      x = pow(i, 2);
      y = pow(j, 2);
      if (x + j == n && i + y == m) {
        counter++;
      }
    }
  }
  cout << counter;
  return 0;
}
