#!/usr/bin/env python

def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x

if __name__ == "__main__":
    x,y=list(map(int,input().split()))
    if x<y:
        tmp=x
        x=y
        y=tmp
    print(GCD(x,y)) def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x GCD while y!=0:
        tmp=y
        y=x%y
        x=tmp
     y!=0 y 0 tmp=y tmp y y=x%y y x%y x y x=tmp x tmp return x x x x y y if __name__ == "__main__":
    x,y=list(map(int,input().split()))
    if x<y:
        tmp=x
        x=y
        y=tmp
    print(GCD(x,y)) __name__ == "__main__" __name__ "__main__" x,y=list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split y 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 print(GCD(x,y)) print GCD(x,y) GCD x y y=list(map(int,input().split())) list(map(int,input().split())) y x=y y x tmp=x x tmp def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x GCD y=tmp tmp y x,y=list(map(int,input().split())) list(map(int,input().split())) x
#!/usr/bin/env python

def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x

if __name__ == "__main__":
    x,y=list(map(int,input().split()))
    if x<y:
        tmp=x
        x=y
        y=tmp
    print(GCD(x,y))