a,b = map(int,raw_input().split(' '))
while(True):
	if(a == b):
		print a
		break
	if(a < b):
		t = a
		a = b
		b = t
	a,b = b,a%b
	if(b == 0):
		print a
		break a,b = map(int,raw_input().split(' ')) a map(int,raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' b while(True):
	if(a == b):
		print a
		break
	if(a < b):
		t = a
		a = b
		b = t
	a,b = b,a%b
	if(b == 0):
		print a
		break True if(a == b):
		print a
		break
	 a == b a b print break if(a < b):
		t = a
		a = b
		b = t
	 a < b a b t = a t a a = b a b b = t b t a,b = b,a%b a b b a%b a b if(b == 0):
		print a
		break b == 0 b 0 print break b = map(int,raw_input().split(' ')) map(int,raw_input().split(' ')) b b = b,a%b a%b b a,b = map(int,raw_input().split(' ')) map(int,raw_input().split(' ')) a a,b = b,a%b b a t = a a t a = b b a b = t t b
a,b = map(int,raw_input().split(' '))
while(True):
	if(a == b):
		print a
		break
	if(a < b):
		t = a
		a = b
		b = t
	a,b = b,a%b
	if(b == 0):
		print a
		break