import Data.List
import Data.Maybe

infAt :: [Int] -> Integer -> Int
infAt ls n = fromMaybe 1 $ find (>1) $ genericTake n ls

main = do
 ls <- map (read . (:[])) <$> getLine
 n <- read <$> getLine
 putStrLn $ show $ infAt ls n