#16D8102008K 1-D Greatest Common Divisor 柳生　葉月　Yagyu Hauzki
import math
a,b=map(int,input().split())
def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd
print(f(a,b))

 import math math a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd f while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
     1 tmp=x%y tmp x%y x y x=y x y y=tmp y tmp if tmp==0:
            gcd=x
            break
     tmp==0 tmp 0 gcd=x gcd x break return gcd gcd x x y y print(f(a,b)) print f(a,b) f a b a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd f
#16D8102008K 1-D Greatest Common Divisor 柳生　葉月　Yagyu Hauzki
import math
a,b=map(int,input().split())
def f(x,y):
    while(1):
        tmp=x%y
        x=y
        y=tmp
        if tmp==0:
            gcd=x
            break
    return gcd
print(f(a,b))


