#coding:UTF-8
def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y)
if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y) def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y) GCD d=0 d 0 if x < y:
        d=y
        y=x
        x=d
     x < y x y d=y d y y=x y x x=d x d if y==0:
        print(x)
    else:
        GCD(y,x%y) y==0 y 0 print(x) print x GCD(y,x%y) GCD y x%y x y x x y y if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y) __name__=="__main__" __name__ "__main__" a=input() a input() input x=int(a.split(" ")[0]) x int(a.split(" ")[0]) int a.split(" ")[0] a.split(" ") a.split a split " " 0 y=int(a.split(" ")[1]) y int(a.split(" ")[1]) int a.split(" ")[1] a.split(" ") a.split a split " " 1 GCD(x,y) GCD x y def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y) def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y) GCD x=int(a.split(" ")[0]) int(a.split(" ")[0]) x y=int(a.split(" ")[1]) int(a.split(" ")[1]) y a=input() input() a
#coding:UTF-8
def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y)
if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y)