#include <bits/stdc++.h>
using namespace std;
int a, b, m, n, answer;
bool found;
int main() {
  cin >> m >> n;
  while (!found) {
    if (((a * a) + b) == n && ((b * b) + a) == m) {
      answer++;
      a = 0;
      b++;
    } else if (((a * a) + b) >= n && ((b * b) + a) <= m) {
      b++;
      a = 0;
    } else if (((b * b) + a) > m) {
      found = true;
    } else {
      a++;
    }
  }
  cout << answer << "\n";
  return 0;
}
