def gcd(x,y):
if x < y:
x,y = y,x
while x%y:
r = x%y
x = y
y = r
return y
# input the first integer:
a = eval(input())
# input the second integer:
b = eval(input())
gcdab = gcd(a,b)
print(gcdab)
# 1 x%y
# 2 r = x%y
# 3 gcd(a,b)
# 4 gcdab


