#include <cstdio>typedef long long LL;
#define int LL
const LL mod = 998244353;
template<typename _T>
void read( _T &x )
{
x = 0;char s = getchar();int f = 1;
while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
x *= f;
}
template<typename _T>
void write( _T x )
{
if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
if( 9 < x ){ write( x / 10 ); }
putchar( x % 10 + '0' );
}
LL N, M;
LL phi( LL x )
{
LL ret = x;
for( int i = 2 ; 1ll * i * i <= x ; i ++ )
if( ! ( x % i ) )
{
ret = ret / i * ( i - 1 );
while( ! ( x % i ) ) x /= i;
}
if( x > 1 ) ret = ret / x * ( x - 1 );
return ret;
}
signed main()
{
read( N ), read( M );
LL a = phi( N ) % mod, b = phi( M ) % mod;
write( 1ll * a * b % mod * ( N % mod ) % mod * ( M % mod ) % mod ), putchar( '\n' );
return 0;
}