#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){ return y ? gcd(y, x%y): x;}
int main(){
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A,B);
  ll s = g;
  ll ans = 1;
  for(ll i=2; i*i<=s; i++){
    if(g%i==0){
      ans+=1;
      while(g%i==0){
        g/=i;
      }
    }
  }
  if(g>1){
    ans++;
  }
  cout << ans;
  
}
