def getResult(a,b):
	if a<b:
		a,b=b,a
	while b!=0:
		r = a%b
		a = b
		b = r
	return a
a,b = map(int,input().strip().split())
print(getResult(a,b)) def getResult(a,b):
	if a<b:
		a,b=b,a
	while b!=0:
		r = a%b
		a = b
		b = r
	return a getResult if a<b:
		a,b=b,a
	 a<b a b a,b=b,a a b b a while b!=0:
		r = a%b
		a = b
		b = r
	 b!=0 b 0 r = a%b r a%b a b a = b a b b = r b r return a a a a b b a,b = map(int,input().strip().split()) a map(int,input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split b print(getResult(a,b)) print getResult(a,b) getResult a b a,b = map(int,input().strip().split()) map(int,input().strip().split()) a def getResult(a,b):
	if a<b:
		a,b=b,a
	while b!=0:
		r = a%b
		a = b
		b = r
	return a def getResult(a,b):
	if a<b:
		a,b=b,a
	while b!=0:
		r = a%b
		a = b
		b = r
	return a getResult b = map(int,input().strip().split()) map(int,input().strip().split()) b
def getResult(a,b):
	if a<b:
		a,b=b,a
	while b!=0:
		r = a%b
		a = b
		b = r
	return a
a,b = map(int,input().strip().split())
print(getResult(a,b))