main :: IO()
main = do
  s <- getLine
  [w] <- map read . words <$> getLine
  putStrLn $ slv s w ""

slv :: String -> Int -> String -> String 
slv [] _ ret = reverse ret
slv (s:ss) w ret = slv (drop w (s:ss)) w (s:ret)
