def gc(x, y):
    while y > 0:
        x %= y
        x, y = y, x
    return x



A = [int(i) for i in input().split()]
print(gc(A[0],A[1])) def gc(x, y):
    while y > 0:
        x %= y
        x, y = y, x
    return x gc while y > 0:
        x %= y
        x, y = y, x
     y > 0 y 0 x %= y x y x, y = y, x x y y x return x x x x y y int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A = [int(i) for i in input().split()] A [int(i) for i in input().split()] print(gc(A[0],A[1])) print gc(A[0],A[1]) gc A[0] A 0 A[1] A 1 A = [int(i) for i in input().split()] [int(i) for i in input().split()] A def gc(x, y):
    while y > 0:
        x %= y
        x, y = y, x
    return x def gc(x, y):
    while y > 0:
        x %= y
        x, y = y, x
    return x gc
def gc(x, y):
    while y > 0:
        x %= y
        x, y = y, x
    return x



A = [int(i) for i in input().split()]
print(gc(A[0],A[1]))
