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