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