def gcd(a,b):
	if a < b:
		a,b = b,a
	while b != 0:
		a,b = b,a%b
	return a

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

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