import math

def gcd(a,b):
    if a<b: a,b=b,a
    c=a%b
    if c==0:
        return b
    else:
        return gcd(b,c)
    
S=[ int(x) for x in input().split()]    
print(gcd(S[0],S[1])) import math math def gcd(a,b):
    if a<b: a,b=b,a
    c=a%b
    if c==0:
        return b
    else:
        return gcd(b,c)
     gcd if a<b: a,b=b,a
     a<b a b c=a%b c a%b a b if c==0:
        return b
    else:
        return gcd(b,c)
     c==0 c 0 return b b return gcd(b,c) gcd(b,c) gcd b c a a b b int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x S=[ int(x) for x in input().split()] S [ int(x) for x in input().split()] print(gcd(S[0],S[1])) print gcd(S[0],S[1]) gcd S[0] S 0 S[1] S 1 S=[ int(x) for x in input().split()] [ int(x) for x in input().split()] S def gcd(a,b):
    if a<b: a,b=b,a
    c=a%b
    if c==0:
        return b
    else:
        return gcd(b,c)
     def gcd(a,b):
    if a<b: a,b=b,a
    c=a%b
    if c==0:
        return b
    else:
        return gcd(b,c)
     gcd
import math

def gcd(a,b):
    if a<b: a,b=b,a
    c=a%b
    if c==0:
        return b
    else:
        return gcd(b,c)
    
S=[ int(x) for x in input().split()]    
print(gcd(S[0],S[1]))
