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

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

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

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

if __name__=='__main__':
	main()