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