#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << "2" << endl;
    return 0;
  }
  for (int i = 0; i < 1001; i++) {
    for (int j = 0; j < 1001; j++) {
      if (((i * i + j) == n) && ((j * j + i) == m)) {
        cout << "1" << endl;
        return 0;
      }
    }
  }
  cout << "0" << endl;
  return 0;
}
