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

s = map(int, raw_input().split())
if s[0] < s[1]:
    print "%d" % gcd(s[1], s[0])
else:
    print "%d" % gcd(s[1], s[0]) def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b) gcd if b == 0:
        return a
    else:
        return gcd(b, a % b) 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 s = map(int, raw_input().split()) s map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split if s[0] < s[1]:
    print "%d" % gcd(s[1], s[0])
else:
    print "%d" % gcd(s[1], s[0]) s[0] < s[1] s[0] s 0 s[1] s 1 print "%d" % gcd(s[1], s[0]) "%d" gcd(s[1], s[0]) gcd s[1] s 1 s[0] s 0 print "%d" % gcd(s[1], s[0]) "%d" gcd(s[1], s[0]) gcd s[1] s 1 s[0] s 0 def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b) def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b) gcd s = map(int, raw_input().split()) map(int, raw_input().split()) s
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

s = map(int, raw_input().split())
if s[0] < s[1]:
    print "%d" % gcd(s[1], s[0])
else:
    print "%d" % gcd(s[1], s[0])