#include <bits/stdc++.h>
using namespace std;
void kick() {
  int m, n;
  cin >> m >> n;
  int cnt = 0;
  if (m < n) swap(m, n);
  for (int i = 0; i * i <= m; i++) {
    int a = m - i * i;
    if (a * a + i == n && i * i + a == m) cnt++;
  }
  cout << cnt << endl;
}
int main() { kick(); }
