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