#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, carry, j, flag = 0;
  cin >> m >> n;
  if (m > n)
    carry = m;
  else
    carry = n;
  for (i = 0; i <= (carry / 2) + 1; i++) {
    for (j = 0; j <= (carry / 2) + 1; j++) {
      if (((i * i + j) == n) && ((j * j + i) == m)) flag++;
    }
  }
  cout << flag;
}
