#include <bits/stdc++.h>
using namespace std;
long long a, b, i, c, x, y, z, k, h;
int main() {
  cin >> x >> y;
  for (a = 0; a <= 1000; a++) {
    for (b = 0; b <= 1000; b++)
      if (a * a + b == x && a + b * b == y) h++;
  }
  cout << h;
}
