Skills Training 2

Bartholomew is doing a multiple choice math test online.

However, the test client seems to have glitched, giving him \(N\) choices to pick from.

The question Bartholomew is trying to currently answer is this: pick any number of choices to add up to number \(M\).

Given number \(M\), \(N\), and then \(N\) multiple choice options, output the smallest number of choices to add up to \(M\) (repeats allowed) and output -1 if it is not possible.

Maybe it wasnt a glitch…


TIME CONSTRAINT: 1s

Sample Input:

100 5
33
66
15
1
24

Sample Output:

3

Submit Solution

Problem author: Vincent