def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

if __name__ == '__main__':
    a, b = [int(x) for x in input().split()]
    print (gcd(a, b)) def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x gcd if x < y:
        tmp = x
        x = y
        y = tmp
     x < y x y tmp = x tmp x x = y x y y = tmp y tmp while y > 0:
        r = x % y
        x = y
        y = r
     y > 0 y 0 r = x % y r x % y x y x = y x y y = r y r return x x x x y y if __name__ == '__main__':
    a, b = [int(x) for x in input().split()]
    print (gcd(a, b)) __name__ == '__main__' __name__ '__main__' int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x a, b = [int(x) for x in input().split()] a [int(x) for x in input().split()] b print (gcd(a, b)) print gcd(a, b) gcd a b b = [int(x) for x in input().split()] [int(x) for x in input().split()] b a, b = [int(x) for x in input().split()] [int(x) for x in input().split()] a def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x gcd
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

if __name__ == '__main__':
    a, b = [int(x) for x in input().split()]
    print (gcd(a, b))
