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

	return b

if __name__ == '__main__':
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]

	ans = gcd(x, y)
	print(ans) def gcd(a, b):
	if a < b:
		tmp = a
		a = b
		b = tmp
	
	r = a % b
	while r != 0:
		a = b
		b = r
		r = a % b

	return b gcd if a < b:
		tmp = a
		a = b
		b = tmp
	
	 a < b a b tmp = a tmp a a = b a b b = tmp b tmp r = a % b r a % b a b while r != 0:
		a = b
		b = r
		r = a % b

	 r != 0 r 0 a = b a b b = r b r r = a % b r a % b a b return b b a a b b if __name__ == '__main__':
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]

	ans = gcd(x, y)
	print(ans) __name__ == '__main__' __name__ '__main__' l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split x = l[0] x l[0] l 0 y = l[1] y l[1] l 1 ans = gcd(x, y) ans gcd(x, y) gcd x y print(ans) print ans ans = gcd(x, y) gcd(x, y) ans l = list(map(int, input().split())) list(map(int, input().split())) l y = l[1] l[1] y def gcd(a, b):
	if a < b:
		tmp = a
		a = b
		b = tmp
	
	r = a % b
	while r != 0:
		a = b
		b = r
		r = a % b

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

	return b gcd x = l[0] l[0] x
def gcd(a, b):
	if a < b:
		tmp = a
		a = b
		b = tmp
	
	r = a % b
	while r != 0:
		a = b
		b = r
		r = a % b

	return b

if __name__ == '__main__':
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]

	ans = gcd(x, y)
	print(ans)