#include <bits/stdc++.h>
using namespace std;
bool inSize(int c, int l, int r) {
  if (c >= l && c <= r) return true;
  return false;
}
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int maxn = 25005;
int main() {
  int n, m, a, b;
  scanf("%d", &(n));
  scanf("%d", &(m));
  int sum = n + m;
  int ans = 0;
  b = 0;
  while (b * (b + 1) <= sum) {
    a = m - b * b;
    if (a >= 0 && a * (a + 1) + b * (b + 1) == sum) {
      ans++;
    }
    b++;
  }
  printf("%d", (ans));
  printf("\n");
  ;
}
