
if __name__ == '__main__':
	s = input().split()
	if s[0] < s[1]:
		tmp = s[0]
		s[0] = s[1]
		s[1] = tmp
	while True:
		x = int(s[0]) % int(s[1])
		if x==0:
			break
		s[0] = s[1]
		s[1] = x

	print (s[1])

 if __name__ == '__main__':
	s = input().split()
	if s[0] < s[1]:
		tmp = s[0]
		s[0] = s[1]
		s[1] = tmp
	while True:
		x = int(s[0]) % int(s[1])
		if x==0:
			break
		s[0] = s[1]
		s[1] = x

	print (s[1]) __name__ == '__main__' __name__ '__main__' s = input().split() s input().split() ().split () input split if s[0] < s[1]:
		tmp = s[0]
		s[0] = s[1]
		s[1] = tmp
	 s[0] < s[1] s[0] s 0 s[1] s 1 tmp = s[0] tmp s[0] s 0 s[0] = s[1] s[0] s 0 s[1] s 1 s[1] = tmp s[1] s 1 tmp while True:
		x = int(s[0]) % int(s[1])
		if x==0:
			break
		s[0] = s[1]
		s[1] = x

	 True x = int(s[0]) % int(s[1]) x int(s[0]) % int(s[1]) int(s[0]) int s[0] s 0 int(s[1]) int s[1] s 1 if x==0:
			break
		 x==0 x 0 break s[0] = s[1] s[0] s 0 s[1] s 1 s[1] = x s[1] s 1 x print (s[1]) print s[1] s 1 x = int(s[0]) % int(s[1]) int(s[0]) % int(s[1]) x tmp = s[0] s[0] tmp s = input().split() input().split() s

if __name__ == '__main__':
	s = input().split()
	if s[0] < s[1]:
		tmp = s[0]
		s[0] = s[1]
		s[1] = tmp
	while True:
		x = int(s[0]) % int(s[1])
		if x==0:
			break
		s[0] = s[1]
		s[1] = x

	print (s[1])


