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