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

a, b = [ int( val ) for val in raw_input( ).split( " " ) ]
if a < b:
	a, b = b, a
print( gcd( a, b ) ) def gcd( x, y ):
	if 1 < y < x:
		return gcd( y, x%y )
	else:
		if y == 1:
			return 1
		return x gcd if 1 < y < x:
		return gcd( y, x%y )
	else:
		if y == 1:
			return 1
		return x 1 < y < x 1 < y 1 y x return gcd( y, x%y ) gcd( y, x%y ) gcd y x%y x y if y == 1:
			return 1
		 y == 1 y 1 return 1 1 return x x x x y y int( val ) for val in raw_input( ).split( " " ) for val in raw_input( ).split( " " ) val raw_input( ).split( " " ) ( ).split ( ) raw_input split " " for val in raw_input( ).split( " " ) int( val ) int val a, b = [ int( val ) for val in raw_input( ).split( " " ) ] a [ int( val ) for val in raw_input( ).split( " " ) ] b if a < b:
	a, b = b, a a < b a b a, b = b, a a b b a print( gcd( a, b ) ) print gcd( a, b ) gcd a b b = b, a a b def gcd( x, y ):
	if 1 < y < x:
		return gcd( y, x%y )
	else:
		if y == 1:
			return 1
		return x def gcd( x, y ):
	if 1 < y < x:
		return gcd( y, x%y )
	else:
		if y == 1:
			return 1
		return x gcd a, b = b, a b a a, b = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] a b = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] b
def gcd( x, y ):
	if 1 < y < x:
		return gcd( y, x%y )
	else:
		if y == 1:
			return 1
		return x

a, b = [ int( val ) for val in raw_input( ).split( " " ) ]
if a < b:
	a, b = b, a
print( gcd( a, b ) )