def gcd(m, n): while n != 0: m, n = n, m % n return m m, n = map(int, input().split()) result = gcd(m, n) print(result)