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