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