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

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

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

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

print gcd(a, b)