#include <cstdio>
using namespace std;
typedef long long ll;
ll A, B, ans = 1;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a%b);
}
int main() {
  scanf("%ld %ld", &A, &B);
  ll M = gcd(A, B), n = M;
  for(ll i = 2; i*i <= M; ++i) {
    if(n%i != 0) continue;
    while(n%i == 0) n /= i;
    ++ans;
  }
  if(n != 1) ++ans;
  printf("%ld\n", ans);
}