#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int a, b, count = 0;
  cin >> n;
  cin >> m;
  {
    b = 0;
    while ((m - b * b) >= 0) {
      if (((b * b * b * b) - (2 * m * b * b) + b + (m * m)) == n) count++;
      b = b + 1;
    }
  }
  cout << count;
  return 0;
}
