#include <bits/stdc++.h>
int main() {
  int n, m, k = 0, a, b, i;
  double c, t;
  scanf("%d%d", &n, &m);
  for (i = 0; i <= n; i++) {
    c = (double)i;
    t = sqrt(c);
    if ((int)t == t) {
      a = (int)t;
      b = n - a * a;
      if (a + b * b == m) {
        k++;
      }
    }
  }
  printf("%d\n", k);
  return 0;
}
