def gcd(m, n) while n != 0 tmp = n n = m % n m = tmp end return m end a, b = gets.split(' ').map{|n| n.to_i} puts gcd(a + b, a * b)