#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int po = 0, i = 0, b, c = 0;
  while (po <= n) {
    po = (int)pow(i, 2);
    b = n - po;
    if ((b * b + i) == m && b >= 0 && po >= 0) c++;
    i++;
  }
  cout << c;
  return 0;
}
