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

#define rep(i, N) for (int i = 0; i < N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#pragma once

#include <algorithm>
#include <vector>
#include <unordered_map>

std::vector<bool> is_primes;
std::vector<unsigned int> primes;

using namespace std;

// Modulo.h start----------------------------------------

#pragma once

#include <vector>
#include <iostream>

unsigned int mod;
struct Modint;
std::vector<Modint> fact_mod;
std::vector<Modint> rev_fact_mod;

using namespace std;

template<typename Tint>
Tint gcd(Tint a, Tint b) {
	// O(log max(a,b))
	a = abs(a);
	b = abs(b);
	return b != 0 ? gcd(b, a % b) : a;
}

template<typename Tint>
Tint lcm(Tint a, Tint b) {
	return a / gcd(a, b) * b;
}

// a x + b y = gcd(a, b)
int extgcd(const unsigned int a, const unsigned int b, int &x, int &y) {
	// O(log max(a,b))
	int g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}

void set_mod(const unsigned int m) {
	mod = m;
}
void set_mod(const int m) {
	if (m > 0)
		set_mod((unsigned int)m);
	else
		std::cout << "Error in set_mod" << std::endl;
}

unsigned int inv_mod(const unsigned int a) {
	int x, y;
	if (extgcd(a, mod, x, y) == 1)
		return (unsigned int)(((long long)x + mod) % mod);
	else // unsolvable
		return 0;
}

struct Modint {
	unsigned int value;
	Modint() { }
	Modint(unsigned int value) : value(value % mod) { }
	Modint(int value) : Modint((unsigned int)(value % mod + mod)) {	}
	Modint(unsigned long long value) : Modint((unsigned int)(value % mod)) { }
	Modint(long long value) : Modint((unsigned int)(value % mod +mod)) { }
	Modint(const Modint& rhs) : Modint(rhs.value) { }
	bool operator==(const Modint& rhs) const;
	inline bool operator!=(const Modint& rhs) const
	{
		return !(*this == rhs);
	}
	Modint& operator+=(const Modint& rhs);
	Modint& operator+=(const unsigned int rhs);
	Modint& operator+=(const int rhs);
	Modint& operator+=(const unsigned long long rhs);
	Modint& operator+=(const long long rhs);
	Modint& operator-=(const Modint& rhs);
	Modint& operator-=(const unsigned int rhs);
	Modint& operator-=(const int rhs);
	Modint& operator-=(const unsigned long long rhs);
	Modint& operator-=(const long long rhs);
	Modint& operator*=(const Modint& rhs);
	Modint& operator*=(const unsigned int rhs);
	Modint& operator*=(const int rhs);
	Modint& operator*=(const unsigned long long rhs);
	Modint& operator*=(const long long rhs);
	Modint& operator/=(const Modint& rhs);
	Modint& operator/=(const unsigned int rhs);
	Modint& operator/=(const int rhs);
	Modint& operator/=(const unsigned long long rhs);
	Modint& operator/=(const long long rhs);
};
bool Modint::operator==(const Modint& rhs) const
{
	return value == rhs.value;
}
Modint& Modint::operator+=(const unsigned int rhs)
{
	unsigned long long tmp = this->value;
	tmp += rhs;
	tmp %= mod;
	this->value = (unsigned int)tmp;
	return *this;
}
Modint& Modint::operator+=(const Modint& rhs)
{
	(*this) += rhs.value;
	return *this;
}
Modint& Modint::operator+=(const int rhs)
{
	(*this) += (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator+=(const unsigned long long rhs)
{
	(*this) += (unsigned int)(rhs % mod);
	return *this;
}
Modint& Modint::operator+=(const long long rhs)
{
	(*this) += (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator-=(const Modint& rhs)
{
	(*this) -= rhs.value;
	return *this;
}
Modint& Modint::operator-=(const unsigned int rhs)
{
	*this += mod - rhs % mod;
	return *this;
}
Modint& Modint::operator-=(const int rhs)
{
	*this -= (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator-=(const unsigned long long rhs)
{
	(*this) -= (unsigned int)(rhs % mod);
	return *this;
}
Modint& Modint::operator-=(const long long rhs)
{
	(*this) -= (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator*=(const Modint& rhs)
{
	(*this) *= rhs.value;
	return *this;
}
Modint& Modint::operator*=(const unsigned int rhs)
{
	unsigned long long tmp = this->value;
	tmp *= rhs;
	tmp %= mod;
	this->value = (unsigned int)tmp;
	return *this;
}
Modint& Modint::operator*=(const int rhs)
{
	(*this) *= (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator*=(const unsigned long long rhs)
{
	(*this) *= (unsigned int)(rhs % mod);
	return *this;
}
Modint& Modint::operator*=(const long long rhs)
{
	(*this) *= (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator/=(const Modint& rhs)
{
	(*this) /= rhs.value;
	return *this;
}
Modint& Modint::operator/=(const unsigned int rhs)
{
	*this *= inv_mod(rhs);
	return *this;
}
Modint& Modint::operator/=(const int rhs)
{
	*this /= (unsigned int)(rhs % mod + mod);
	return *this;
}
Modint& Modint::operator/=(const unsigned long long rhs)
{
	*this /= (unsigned int)(rhs % mod);
	return *this;
}
Modint& Modint::operator/=(const long long rhs)
{
	*this /= (unsigned int)(rhs % mod + mod);
	return *this;
}
const Modint operator + (const Modint& lhs, const Modint& rhs) {
	return Modint(lhs) += rhs;
}
const Modint operator + (const Modint& lhs, unsigned int rhs) {
	return Modint(lhs) += rhs;
}
const Modint operator + (unsigned int lhs, const Modint& rhs) {
	return Modint(lhs) += rhs;
}
const Modint operator - (const Modint& lhs, const Modint& rhs) {
	return Modint(lhs) -= rhs;
}
const Modint operator - (const Modint& lhs, unsigned int rhs) {
	return Modint(lhs) -= rhs;
}
const Modint operator - (unsigned int lhs, const Modint& rhs) {
	return Modint(lhs) -= rhs;
}
const Modint operator * (const Modint& lhs, const Modint& rhs) {
	return Modint(lhs) *= rhs;
}
const Modint operator * (const Modint& lhs, unsigned int rhs) {
	return Modint(lhs) *= rhs;
}
const Modint operator * (unsigned int lhs, const Modint& rhs) {
	return Modint(lhs) *= rhs;
}
const Modint operator / (const Modint& lhs, const Modint& rhs) {
	return Modint(lhs) /= rhs;
}
const Modint operator / (const Modint& lhs, unsigned int rhs) {
	return Modint(lhs) /= rhs;
}
const Modint operator / (unsigned int lhs, const Modint& rhs) {
	return Modint(lhs) /= rhs;
}
ostream& operator<<(std::ostream& lhs, const Modint& rhs)
{
	lhs << rhs.value;
	return lhs;
}

Modint pow_mod(const Modint& x, const unsigned int k) { //x^k (mod)
	if (k == 0)     return Modint(1);
	if (k % 2 == 0) return pow_mod(x*x, k / 2);
	else            return x * pow_mod(x, k - 1);
}
Modint pow_mod(const unsigned int x, const unsigned int k) {
	return pow_mod(Modint(x), k);
}

std::vector<Modint> set_fact_mod(unsigned int n) {
	fact_mod = vector<Modint>(n + 1);
	fact_mod[0] = 1;
	for (unsigned int i = 1; i <= n; i++)
	{
		fact_mod[i] = fact_mod[i - 1] * i;
	}
	return fact_mod;
}

std::vector<Modint> set_rev_fact_mod(unsigned int n) {
	rev_fact_mod = vector<Modint>(n + 1);
	rev_fact_mod[n] = 1 / fact_mod[n];
	for (int i = n - 1; i >= 0; i--)
	{
		rev_fact_mod[i] = rev_fact_mod[i + 1] * (unsigned int)(i + 1);
	}
	return rev_fact_mod;
}

Modint combination_mod_precalculation(unsigned int n, unsigned int r) {
	//set mod, fact_mod, rev_fact_mod
	return fact_mod[n] * rev_fact_mod[r] * rev_fact_mod[n - r];
}

Modint combination_mod_straightforward(unsigned long long n, unsigned long long r) { //mod is prime
	if (r * 2 > n) r = n - r;
	Modint numerator = 1;
	Modint denominator = 1;
	for (unsigned long long i = 1; i <= r; ++i) {
		numerator *= n - i + 1;
		denominator *= i;
	}
	return numerator / denominator;
}

// Modulo.h end----------------------------------------------

void set_is_primes(unsigned int n)
{
	//sieve_of_eratosthenes
	//is_primes : [0, n] �̔z��ŁCprimes[i] = true iff i �͑f��
	//O(n log n)
	is_primes.assign(n + 1, true);
	for (unsigned int i = 0; i <= min((unsigned int)1, n); ++i)
		is_primes[i] = false;
	for (unsigned int i = 2; i * i <= n; ++i)
		if (is_primes[i])
			for (unsigned int j = i * i; j <= n; j += i)
				is_primes[j] = false;
	return;
}

void set_primes(unsigned int n)
{
	//sieve_of_eratosthenes
	//primes : n�ȉ��̑f���̃��X�g
	//O(n log n)
	primes.assign(n + 1, 0);
	for (unsigned int i = 2; i <= min((unsigned int)1, n); ++i)
		primes[i] = i;
	for (unsigned int i = 2; i * i <= n; ++i)
		if (primes[i])
			for (unsigned int j = i * i; j <= n; j += i)
				primes[j] = 0;
	primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
	return;
}

vector<bool> make_is_prime_segments(unsigned long long L, unsigned long long H)
{
	//��Ԃӂ邢
	//is_primes : [L, H] �̔z��ŁCprimes[i] = true iff i �͑f��
	//O((H-L) sqrt( H ) / log(H))
	vector<bool> is_prime_segments(H - L + 1, true);
	for (int i = 0; (unsigned long long)primes[i] * primes[i] <= H; ++i)
	{ // O( \sqrt(H) )
		unsigned long long j;
		if (primes[i] >= L)
			j = primes[i] * primes[i];
		else if (L % primes[i] == 0)
			j = L;
		else
			j = L - (L % primes[i]) + primes[i];
		for (; j <= H; j += primes[i])
			is_prime_segments[j - L] = false;
	}
	return is_prime_segments;
}

bool is_prime(const int n, const bool is_using_is_primes)
{
	if (n <= 1)
		return false;
	for (int i = 2; i * i <= n; i++)
	{
		if (is_using_is_primes && !is_primes[i])
			continue;
		if (n % i == 0)
			return false;
	}
	return true;
}

vector<unsigned int> make_divisors(const unsigned int n)
{
	vector<unsigned int> ans;
	for (unsigned int i = 1; i * i <= n; i++)
		if (n % i == 0)
			ans.emplace_back(i);
	vector<unsigned int> latter;
	const auto rit_b = ans.crbegin();
	const bool is_square = (*rit_b * *rit_b == n);
	for (auto rit = rit_b + (is_square ? 1 : 0), rit_e = ans.crend(); rit != rit_e; rit++)
		latter.emplace_back(n / *rit);
	ans.insert(ans.end(), latter.begin(), latter.end());
	return ans;
}

vector<unsigned long long> make_divisors(const unsigned long long n)
{
	vector<unsigned long long> ans;
	for (unsigned long long i = 1; i * i <= n; i++)
		if (n % i == 0)
			ans.emplace_back(i);
	vector<unsigned long long> latter;
	const auto rit_b = ans.crbegin();
	const bool is_square = (*rit_b * *rit_b == n);
	for (auto rit = rit_b + (is_square ? 1 : 0), rit_e = ans.crend(); rit != rit_e; rit++)
		latter.emplace_back(n / *rit);
	ans.insert(ans.end(), latter.begin(), latter.end());
	return ans;
}

unordered_map<unsigned int, unsigned int> make_prime_factors(unsigned int n, const bool is_using_primes)
{
	//O(sqrt(n))
	unordered_map<unsigned int, unsigned int> prime_factors;
	for (unsigned int i = 2; i * i <= n; i++)
	{
		if (is_using_primes && !is_primes[i])
			continue;
		while (n % i == 0)
		{
			++prime_factors[i];
			n /= i;
		}
	}
	if (n != 1)
		++prime_factors[n];
	return prime_factors;
}

unordered_map<unsigned long long, unsigned int> make_prime_factors(unsigned long long n, const bool is_using_primes)
{
	//O(sqrt(n))
	unordered_map<unsigned long long, unsigned int> prime_factors;
	for (unsigned long long i = 2; i * i <= n; i++)
	{
		if (is_using_primes && !is_primes[i])
			continue;
		while (n % i == 0)
		{
			++prime_factors[i];
			n /= i;
		}
	}
	if (n != 1)
		++prime_factors[n];
	return prime_factors;
}

void solve()
{
    ll A, B;
    cin >> A >> B;
    unsigned long long g = gcd(A, B);
    unordered_map<unsigned long long, unsigned int> prime_factors = make_prime_factors(g, false);
    cout << prime_factors.size() + 1 << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256