#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n;
  scanf("%lld %lld", &n, &m);
  long long cnt = 0;
  for (long long i = 0; i <= 1000; i++) {
    for (long long j = 0; j <= 1000; j++) {
      long long f = i * i + j;
      long long s = i + j * j;
      if (f == n and s == m) cnt++;
    }
  }
  printf("%lld\n", cnt);
}
