#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c = 0;
  cin >> n >> m;
  int a = 0;
  while (a * a <= n) {
    double res = a * a + (double)sqrt((m - a));
    if ((res) == n) c++;
    a++;
  }
  cout << c;
}
