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

int main() {
  unsigned long a, b, r, i, j;
  cin >> a >> b;
  if (a < b) swap(a, b);
  while (a%b != 0) {
    r = a%b; a = b; b = r;
  }
  int ans = 1, lim = sqrt(b);
  for (i = 2; i <= lim; i++) {
    if (b%i == 0) {
      ans++; while (b%i == 0) b /= i;
    }
  }
  if (b > lim) ans++;
  cout << ans << endl;
}