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