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