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