def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b)
A,B=map(int,input().split())
print(gcd(A,B))
 def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b) gcd a=max(x,y) a max(x,y) max x y b=min(x,y) b min(x,y) min x y if a%b==0:
        return b
    else:
        return gcd(a%b,b) a%b==0 a%b a b 0 return b b return gcd(a%b,b) gcd(a%b,b) gcd a%b a b b x x y y A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B print(gcd(A,B)) print gcd(A,B) gcd A B def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b) def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b) gcd A,B=map(int,input().split()) map(int,input().split()) A B=map(int,input().split()) map(int,input().split()) B
def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b)
A,B=map(int,input().split())
print(gcd(A,B))

