unittest
{
	assert( [ "12 18" ].parse.expand.solve == 3 );
	assert( [ "420 660" ].parse.expand.solve == 4 );
	assert( [ "1 2019" ].parse.expand.solve == 1 );
	
	assert( [ "1000000000000 1000000000000" ].parse.expand.solve == 3 );		// 追加ケース
	assert( [ "999999999999 999999999999" ].parse.expand.solve == 8 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	// 公約数のうち、素数のものをカウント
	auto ps = ( ( cast( long ) min( a, b ) ^^ 0.5 ) + 1 ).primes;
	auto aps = a.primefactorize( ps ).uniq;
	auto bps = b.primefactorize( ps ).uniq;
	auto ans = 1L;
	while( !aps.empty && !bps.empty )
	{
		if( aps.front < bps.front )
		{
			aps.popFront;
		}
		else if( bps.front < aps.front )
		{
			bps.popFront;
		}
		else
		{
			ans++;
			aps.popFront;
			bps.popFront;
		}
	}
	return ans;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}

// 素因数分解
auto primefactorize( long x, long[] ps )
{
	Appender!( long[] ) fs;
	if( x < 2 ) return fs.data;
	
	auto s = ( cast( long ) x ^^ 0.5 ) + 1;
	foreach( p; ps )
	{
		if( s < p ) break;
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
		if( x < 2 ) break;
	}
	if( 2 <= x ) fs ~= x;
	return fs.data;
}
