import Control.Applicative
import Control.Monad
import Data.Char

solver :: String -> Integer  -> Char
solver (x:xs) k =
    let l = digitToInt x
        n = fromIntegral l :: Integer
        m = n^5000
        in if m < k then solver xs (k-m) else x

main :: IO ()
main = do
    s <- getLine
    k <- read <$> getLine
    putChar $ solver s k
    putChar '\n'
