find'::Eq a=>a->[] a->Int
find' x [] = 0
find' x (y:ys) =
  if y == x
    then 0
    else 1 + find' x ys
split::Char->String->[] String
split x [] = []
split x ys = take n ys : (split x $drop (n+1) ys)
  where
    n = find' x ys
toInt::String->Int
toInt = read
gcd'::Int->Int->Int
gcd' x 0 = x
gcd' 0 y = y
gcd' x y
  | x < y = gcd' x $mod y x
  | otherwise = gcd' (mod x y) y
main = do
  a <- getLine
  let b:c:_ = map toInt $split ' ' a
  print $gcd b c
