#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a, b;
  int count = 0;
  int mi = min(n, m);
  for (int i = 0; i <= mi; i++) {
    a = m - pow(i, 2);
    if (pow(a, 2) + i == n and a >= 0) {
      count++;
    }
  }
  cout << count;
  return 0;
}
