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