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