import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:k:as)=g(-1)$V.length bs where
  bs=V.fromList.sort.filter(<k)$as
  f j=V.or.V.slice(k-c)c.V.ifoldr(\i a v->if i==j then v else V.imap(\i b->b || (i>=a && v V.!(i-a)))v)(V.generate k(==0))$bs
    where c=bs V.! j
  g l r
    |l+1>=r=r
    |f m=g l m
    |otherwise=g m r
    where m=(l+r)`div`2