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