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