def gcd(x, y):
	if x < y:
		tmp = y
		y = x
		x = tmp
	
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number
l = raw_input()

x, y = [int(e) for e in l.split()]
 
if x < 1 and x > 10000000000:
	exit()

if y < 1 and y > 10000000000:
	exit()

print gcd(x, y) def gcd(x, y):
	if x < y:
		tmp = y
		y = x
		x = tmp
	
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number gcd if x < y:
		tmp = y
		y = x
		x = tmp
	
	 x < y x y tmp = y tmp y y = x y x x = tmp x tmp if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number x % y == 0 x % y x y 0 return y y return gcd(y, x % y) gcd(y, x % y) gcd y x % y x y x x y y l = raw_input() l raw_input() raw_input int(e) for e in l.split() for e in l.split() e l.split() l.split l split for e in l.split() int(e) int e x, y = [int(e) for e in l.split()] x [int(e) for e in l.split()] y if x < 1 and x > 10000000000:
	exit() x < 1 and x > 10000000000 x < 1 x 1 x > 10000000000 x 10000000000 exit() exit if y < 1 and y > 10000000000:
	exit() y < 1 and y > 10000000000 y < 1 y 1 y > 10000000000 y 10000000000 exit() exit print gcd(x, y) gcd x y x, y = [int(e) for e in l.split()] [int(e) for e in l.split()] x l = raw_input() raw_input() l y = [int(e) for e in l.split()] [int(e) for e in l.split()] y def gcd(x, y):
	if x < y:
		tmp = y
		y = x
		x = tmp
	
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number def gcd(x, y):
	if x < y:
		tmp = y
		y = x
		x = tmp
	
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number gcd
def gcd(x, y):
	if x < y:
		tmp = y
		y = x
		x = tmp
	
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number
l = raw_input()

x, y = [int(e) for e in l.split()]
 
if x < 1 and x > 10000000000:
	exit()

if y < 1 and y > 10000000000:
	exit()

print gcd(x, y)