{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here

import Data.Vector.Generic ((!))

-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

-- ----------

step' :: Int -> UVector Bool -> Int
step' m ss
	| m <= 0    = -1
	| len <= m  = step' (len - 1) ss
 	| ss ! m    = m
	| otherwise = step' (m - 1) ss
	where len = UVector.length ss

step :: Int -> UVector Bool -> (Int, UVector Bool)
step m ss = (n, UVector.drop n ss)
	where n = step' m ss

steps' :: Int -> [Int] -> UVector Bool -> [Int]
steps' m results ss
	| UVector.length ss <= 1 = results
	| n < 0                  = [-1]
	| otherwise              = steps' m (n:results) ss'
		where
			(n, ss') = step m ss

steps :: Int -> UVector Bool -> [Int]
steps m ss = steps' m [] ss

readBool :: ByteString -> Maybe (Bool, ByteString)
readBool bs
	| BS.null bs = Nothing
	| otherwise  = Just (BS.head bs == '0', BS.tail bs)

main :: IO ()
main = do
	[n, m] <- map read . words <$> getLine :: IO [Int]
	sstr <- BS.reverse <$> BS.getLine
	let ss = UVector.unfoldr readBool $ sstr
	forM_ (steps m ss) (\s -> putStr $ show s ++ " ")
	putStrLn ""


Measured memory_bytes: 6012