#include <cstdio>
#define ll long long
ll gcd(ll a, ll b){
	while (b) b ^= a ^= b ^= a %= b;
	return a;
}
int main(){
	ll a, b;
	scanf("%lld %lld", &a, &b);
	ll g = gcd(a, b), c = 1;
	for (ll i = 2; i <= 1000000; i++){
		if (g % i == 0){
			c++;
			while (g % i == 0) g /= i;
			if (g == 1) break;
		}
	}
	if (g != 1) c++;
	printf("%lld\n", c);
}