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