#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, j, f, s = 0, u, v;
  cin >> n >> k;
  for (f = 0; f < 34; f++)
    for (j = 0; j < 34; j++)
      if (f * f + j == n && f + j * j == k) s++;
  cout << s;
}
