#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;


//E
/*
struct LLPair {
	LL price = 0;
	LL open = 0;
};

int main() {
	LL N, M;
	scanf("%lld %lld", &N, &M);

	vector<LLPair> key;

	for (LL i = 0; i < M; i++) {
		LLPair p;

		LL price, num;
		scanf("%lld %lld", &price, &num);

		p.price = price;
		for (LL j = 0; j < num; j++) {
			LL val;
			scanf("%lld", &val);

			val -= 1; //�󔠔ԍ���0����n�܂�悤�ɂ���

			p.open |= (1 << val);
		}

		key.push_back(p);
	}

	static LL dp[1010][4096];

	for (LL i = 0; i <= M; i++) {
		for (LL j = 0; j < (1 << N); j++) {
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 0;
	//memset(dp, 0, sizeof(dp));

	for (LL i = 0; i < M; i++) {
		for (LL j = 0; j < (1 << N); j++) {
			if (dp[i][j] < 0) {
				continue;
			}

			//��i���g��Ȃ��ꍇ
			LL nextJ = j;
			LL nextPrice = dp[i][j];
			
			if (dp[i + 1][nextJ] < 0 || nextPrice < dp[i + 1][nextJ]) {
				dp[i + 1][nextJ] = nextPrice;
			}

			//��i���g���ꍇ
			nextJ |= key[i].open;
			nextPrice += key[i].price;

			if (dp[i + 1][nextJ] < 0 || nextPrice < dp[i + 1][nextJ]) {
				dp[i + 1][nextJ] = nextPrice;
			}
		}
	}

	printf("%lld\n", dp[M][(1 << N) - 1]);
}
*/


//D
//�ő����
ll GCD(ll a, ll b) {
	if (a < b) {
		ll temp = a;
		a = b;
		b = temp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

bool Prime(ll x) {
	if (x == 1 || x == 2) {
		return true;
	}

	if (x % 2 == 0) {
		return false;
	}

	for (ll i = 3; i <= (ll)std::sqrt(x); i += 2) {
		if (x % i == 0) {
			return false;
		}
	}

	return true;
}

void decompositPrime(ll n, map<ll, ll> &result)
{
	result.clear();

	// ���鐔�̏����l
	ll a = 2;

	// ��n �� a ( n �� a * a ) �̊ԃ��[�v����
	while (n >= a * a) {
		// a �Ŋ���؂ꂽ��Aa �͑f����
		// �����āA�����鐔�� a �Ŋ���
		// a �Ŋ���؂�Ȃ�������A a �� 1 ����������
		if (n % a == 0) {
			//printf("%d * ", a);
			result[a]++;
			n /= a;
		}
		else {
			a++;
		}
	}

	// �Ō�Ɏc���� n �͑f����
	//printf("%d\n", n);
	result[n]++;
}

int main() {
	ll A, B;
	scanf("%lld %lld", &A, &B);

	ll g = GCD(A, B);

	map<ll, ll> prime_factor;
	decompositPrime(g, prime_factor);

	prime_factor[1]++;  //+1�͖�1�̕�(���ł�1�����݂�����J�E���g�͕ςɂȂ邪key���ɈႢ�͂Ȃ�)
	ll result = prime_factor.size();

	printf("%lld\n", result);
}


//C
/*
struct LLPair
{
	LL a = 0;
	LL b = 0;
};

int main() {
	LL N;
	scanf("%lldd", &N);

	vector<LLPair> A;
	for (LL i = 1; i <= N; i++) {
		LL a;
		scanf("%lld", &a);

		LLPair p;
		p.a = i;
		p.b = a;

		A.push_back(p);
	}

	std::sort(A.begin(), A.end(), [](const LLPair &a, const LLPair &b) {
		return a.b < b.b;
	});

	for (auto item : A) {
		printf("%lld ", item.a);
	}

	printf("\n");

	return 0;
}
*/


//B
/*
int main() {
	LL N, K;
	scanf("%lld %lld", &N, &K);

	LL result = 0;

	for (LL i = 0; i < N; i++) {
		LL h;
		scanf("%lld", &h);

		if (h >= K) {
			result++;
		}
	}

	printf("%lld\n", result);

	return 0;
}
*/

//A
/*
int main() {
	LL N;

	scanf("%lld", &N);

	double result = (double)((N + 1) / 2) / (double)N;

	printf("%0.9f\n", result);

	return 0;
}
*/

Measured memory_bytes: 256