#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b, res;
int main() {
  cin >> n >> m;
  for (a = 0; a <= 1000; a++) {
    for (b = 0; b <= 1000; b++) {
      if (a * a + b == n && a + b * b == m) {
        res++;
      }
    }
  }
  cout << res;
}
