def gcd(a,b):
    if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

    if y==0:
        return x
    else:
        return gcd(y,x%y)

p,q=[int(i) for i in input().split(" ")]
print(gcd(p,q)) def gcd(a,b):
    if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

    if y==0:
        return x
    else:
        return gcd(y,x%y) gcd if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

     a>b a b x=a x a y=b y b x=b x b y=a y a if y==0:
        return x
    else:
        return gcd(y,x%y) y==0 y 0 return x x return gcd(y,x%y) gcd(y,x%y) gcd y x%y x y a a b b 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 p,q=[int(i) for i in input().split(" ")] p [int(i) for i in input().split(" ")] q print(gcd(p,q)) print gcd(p,q) gcd p q q=[int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] q def gcd(a,b):
    if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

    if y==0:
        return x
    else:
        return gcd(y,x%y) def gcd(a,b):
    if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

    if y==0:
        return x
    else:
        return gcd(y,x%y) gcd p,q=[int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] p
def gcd(a,b):
    if a>b:
        x=a
        y=b
    else:
        x=b
        y=a

    if y==0:
        return x
    else:
        return gcd(y,x%y)

p,q=[int(i) for i in input().split(" ")]
print(gcd(p,q))