#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t a,b,c,i;
  cin>>a>>b;
  if(a>b) swap(a,b);
  c=b%a;
  while(c>0){
    b=a;
    a=c;
    c=b%a;
  }
  int64_t ans=1;
  for(i=2;i*i<=a;i++){
    if(a%i==0){
      ans++;
      while(a%i==0) a/=i;
      if(a==1) break;
    }
  }
  if(a>1) ans++;
  cout<<ans<<endl;
}