#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a = 0;
  int b = 0;
  vector<pair<int, int> > V;
  for (int i = n; i >= 0; i--) {
    int aux = sqrt(n - i);
    if ((aux * aux) == n - i) {
      V.push_back(make_pair(aux, i));
    }
  }
  int c = 0;
  for (int i = 0; i < V.size(); i++) {
    if (V[i].first + (V[i].second * V[i].second) == m) c++;
  }
  cout << c << "\n";
  return 0;
}
