def gcd(x,y)
 min = x<=y ? x : y
 result = 1
 unless x<=y
  min.times{|i|
   result=i+1 if x%(i+1)==0 && y%(i+1)==0
  }
 else
  min.times{|i|
   result=i+1 if y%(i+1)==0 && (x%y)%(i+1)==0
  }
 end
 result
 
end
x,y=gets.split.map{|num|num.to_i}
puts gcd x,y