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