#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  int k = 0;
  for (int i = 0; i * i <= n; i++) {
    for (int j = 0; j * j <= m; j++) {
      if (i * i + j == n && j * j + i == m) {
        k++;
      }
    }
  }
  printf("%d\n", k);
}
int main() {
  solve();
  return 0;
}
