module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.math;
import std.stdio;
import std.string;

struct Input
{
	ulong a,b;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto ab = readln().strip().split();
		a = ab[0].to!ulong;
		b = ab[1].to!ulong;
	}
}

T gcm(T)(T i1, T i2)
{
	T large = i1 < i2 ? i2 : i1;
	T small = i1 < i2 ? i1 : i2;

	while (small != 0)
	{
		T q = large % small;

		large = small;
		small = q;
	}

	return large;
}

auto main2(Input* input)
{
	ulong[] primes = [2];

	auto gcm = gcm(input.a, input.b);

	if (input.a == input.b)
	{

	}

	bool isPrime(ulong n)
	{
		auto r = floor(sqrt(cast(real)n));
		foreach (p; primes)
		{
			if (p > r)
				return true;

			if (n % p == 0)
				return false;
		}
		return true;
	}

	uint result = 1;
	
	{
		bool contains = false;
		while (gcm % 2 == 0)
		{
			gcm /= 2;
			contains = true;
		}

		if (contains)
			result++;
	}

	for (ulong n = 3; gcm != 1; n+=2)
	{
		if (isPrime(n))
			primes ~= n;
		else
		{
			if (n > sqrt(floor(cast(real)gcm)))
			{
				result++;
				break;
			}

			continue;
		}

		bool contains = false;
		while (gcm % n == 0)
		{
			gcm /= n;
			contains = true;
		}

		if (contains)
			result++;
	}

	return result;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`12 18`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 3);
}

unittest // example2
{
	string example =
`420 660`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 4);
}

unittest // example3
{
	string example =
`1 2019`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 1);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}
