def _gcd(a, b)
    return a if b == 0
    gcd(b, a % b)
end

def gcd(a, b)
    if a < b
        tmp = a
        a = b
        b = tmp
    end
    
    _gcd(a, b)
end

a, b = gets.chomp.split.map(&:to_i)

puts gcd(a, b)
