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