def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a 
def lcm(a, b): 
    return a * b // gcd (a, b) 

c,d=[int(i) for i in input().split()]

print(gcd(c,d)) def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a  gcd while b: 
        a, b = b, a % b 
     b a, b = b, a % b a b b a % b a b return a a a a b b def lcm(a, b): 
    return a * b // gcd (a, b)  lcm return a * b // gcd (a, b) a * b // gcd (a, b) a * b a b gcd (a, b) gcd a b 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 c,d=[int(i) for i in input().split()] c [int(i) for i in input().split()] d print(gcd(c,d)) print gcd(c,d) gcd c d def lcm(a, b): 
    return a * b // gcd (a, b)  def lcm(a, b): 
    return a * b // gcd (a, b)  lcm c,d=[int(i) for i in input().split()] [int(i) for i in input().split()] c d=[int(i) for i in input().split()] [int(i) for i in input().split()] d def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a  def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a  gcd
def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a 
def lcm(a, b): 
    return a * b // gcd (a, b) 

c,d=[int(i) for i in input().split()]

print(gcd(c,d))