#include <bits/stdc++.h>
int minimum(int num1, int num2) {
  if (num1 <= num2)
    return num1;
  else
    return num2;
}
int main() {
  int a, b, counter = 0;
  scanf("%d %d", &a, &b);
  int min = minimum(a, b);
  for (int i = 0; i <= min; i++) {
    for (int j = 0; j <= min; j++) {
      if ((i * i) + j == a && i + (j * j) == b) {
        counter++;
      }
    }
  }
  printf("%d\n", counter);
  return 0;
}
