#--coding:utf-8

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

x, y = map(int, raw_input().split())
print gcd(x, y) def gcd(x, y):
    if x < y:
        gcd(y,x)
    if x%y == 0:
        return y 
    else:
        return gcd(y, x%y) gcd if x < y:
        gcd(y,x)
     x < y x y gcd(y,x) gcd y x if x%y == 0:
        return y 
    else:
        return gcd(y, x%y) x%y == 0 x%y x y 0 return y y return gcd(y, x%y) gcd(y, x%y) gcd y x%y x y x x y y x, y = map(int, raw_input().split()) x map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split y print gcd(x, y) gcd x y y = map(int, raw_input().split()) map(int, raw_input().split()) y def gcd(x, y):
    if x < y:
        gcd(y,x)
    if x%y == 0:
        return y 
    else:
        return gcd(y, x%y) def gcd(x, y):
    if x < y:
        gcd(y,x)
    if x%y == 0:
        return y 
    else:
        return gcd(y, x%y) gcd x, y = map(int, raw_input().split()) map(int, raw_input().split()) x
#--coding:utf-8

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

x, y = map(int, raw_input().split())
print gcd(x, y)