#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, m, count;
  scanf("%d%d", &n, &m);
  count = 0;
  for (i = 0; i <= 1000; ++i)
    for (j = 0; j <= 1000; ++j) {
      if ((((i * i) + j) == n) && ((i + (j * j)) == m)) ++count;
    }
  printf("%d", count);
  return 0;
}
