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