#16D8101012J 伊藤惇 dj Python3 

def Greatest_Common_Divisor(x,y):
    if y>x:
        x,y=y,x
    if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
    return x

if __name__ == "__main__":
    x=list(map(int,input().split()))
    print(Greatest_Common_Divisor(x[0],x[1]))

 def Greatest_Common_Divisor(x,y):
    if y>x:
        x,y=y,x
    if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
    return x Greatest_Common_Divisor if y>x:
        x,y=y,x
     y>x y x x,y=y,x x y y x if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
     x>=y and y>0 x>=y x y y>0 y 0 return Greatest_Common_Divisor(y,x%y) Greatest_Common_Divisor(y,x%y) Greatest_Common_Divisor y x%y x y return x x x x y y if __name__ == "__main__":
    x=list(map(int,input().split()))
    print(Greatest_Common_Divisor(x[0],x[1])) __name__ == "__main__" __name__ "__main__" x=list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split print(Greatest_Common_Divisor(x[0],x[1])) print Greatest_Common_Divisor(x[0],x[1]) Greatest_Common_Divisor x[0] x 0 x[1] x 1 x=list(map(int,input().split())) list(map(int,input().split())) x def Greatest_Common_Divisor(x,y):
    if y>x:
        x,y=y,x
    if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
    return x def Greatest_Common_Divisor(x,y):
    if y>x:
        x,y=y,x
    if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
    return x Greatest_Common_Divisor
#16D8101012J 伊藤惇 dj Python3 

def Greatest_Common_Divisor(x,y):
    if y>x:
        x,y=y,x
    if x>=y and y>0:
        return Greatest_Common_Divisor(y,x%y)
    return x

if __name__ == "__main__":
    x=list(map(int,input().split()))
    print(Greatest_Common_Divisor(x[0],x[1]))


