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