#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t A,B,C,ans=1;
  cin >> A >> B;
  while(B!=0){
    A%=B;
    swap(A,B);
  }
  C = A;
  for (int64_t i=2; i*i<=C; i++) {
        if (C%i == 0) {
          ans++;
          while(C%i==0) {
            C /= i;
          }
        }
    }
  if (C > 1) {
    ans++;
  } 
  cout << ans << endl;
}

