{-# LANGUAGE TypeApplications #-}

main :: IO ()
main = do
  l1 <- getLine
  let xs@[x1, x2, x3, x4, x5] = map (read @Int) $ words l1
  print $ f 1 xs

f i [] = undefined 
f i (x:xs) = if i == x then f (i + 1) xs else i
