def gcd(a,b):
    if b == 1:
        return 1
    elif b == 0:
        return a
    else:
        return gcd(b,a%b)

a,b = map(int, raw_input().split(' '))
if a > b:
    print gcd(a,b)
else:
    print gcd(b,a) def gcd(a,b):
    if b == 1:
        return 1
    elif b == 0:
        return a
    else:
        return gcd(b,a%b) gcd if b == 1:
        return 1
    elif b == 0:
        return a
    else:
        return gcd(b,a%b) b == 1 b 1 return 1 1 elif b == 0:
        return a
     b == 0 b 0 return a a return gcd(b,a%b) gcd(b,a%b) gcd b a%b a b a a b b a,b = map(int, raw_input().split(' ')) a map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' b if a > b:
    print gcd(a,b)
else:
    print gcd(b,a) a > b a b print gcd(a,b) gcd a b print gcd(b,a) gcd b a def gcd(a,b):
    if b == 1:
        return 1
    elif b == 0:
        return a
    else:
        return gcd(b,a%b) def gcd(a,b):
    if b == 1:
        return 1
    elif b == 0:
        return a
    else:
        return gcd(b,a%b) gcd a,b = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) a b = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) b
def gcd(a,b):
    if b == 1:
        return 1
    elif b == 0:
        return a
    else:
        return gcd(b,a%b)

a,b = map(int, raw_input().split(' '))
if a > b:
    print gcd(a,b)
else:
    print gcd(b,a)