a,b = gets.split.map(&:to_i) wa = a + b seki = a * b def gcd(a, b) return b == 0 ? a : gcd(b, a % b) end puts gcd(wa, seki)