a, b = map(int, raw_input().split())

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

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

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

if a > b:
	print gcd(a, b)
elif a < b:
	print gcd(b, a)
else:
	print a