#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else {
    return gcd(b, a % b);
  }
}
int main() {
  long long int a, b;
  cin >> a >> b;
  bool n = gcd(a, b);
  long long int prime[n + 1];
  memset(prime, true, sizeof(prime));
  long long int count = 1;
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long int i = 2; i <= n; i++) {
    if (prime[i] == true && n % i == 0) {
      count++;
    }
  }
  cout << count;
}
