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