import sys

input_list = map(int, raw_input().split())

x = input_list[0]
y = input_list[1]

if x < y:
	tmp = x
	x = y
	y = tmp
elif x == y:
	print(x)
	sys.exit(0)


r = 0
while y != 0:
	r = x % y
	x = y
	y = r

print(x)
	
 import sys sys input_list = map(int, raw_input().split()) input_list map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split x = input_list[0] x input_list[0] input_list 0 y = input_list[1] y input_list[1] input_list 1 if x < y:
	tmp = x
	x = y
	y = tmp
elif x == y:
	print(x)
	sys.exit(0) x < y x y tmp = x tmp x x = y x y y = tmp y tmp elif x == y:
	print(x)
	sys.exit(0) x == y x y print(x) print x sys.exit(0) sys.exit sys exit 0 r = 0 r 0 while y != 0:
	r = x % y
	x = y
	y = r y != 0 y 0 r = x % y r x % y x y x = y x y y = r y r print(x) print x y = tmp tmp y tmp = x x tmp x = input_list[0] input_list[0] x r = x % y x % y r y = r r y x = y y x y = input_list[1] input_list[1] y x = y y x input_list = map(int, raw_input().split()) map(int, raw_input().split()) input_list r = 0 0 r
import sys

input_list = map(int, raw_input().split())

x = input_list[0]
y = input_list[1]

if x < y:
	tmp = x
	x = y
	y = tmp
elif x == y:
	print(x)
	sys.exit(0)


r = 0
while y != 0:
	r = x % y
	x = y
	y = r

print(x)
	

