Problem1064--Y = Y/2

1064: Y = Y/2

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

Given a integer X, and a list of integers (N of them), we need to make X into a non-positive integer by the following operations:
choose any number Y from the list and then reduce X by Y ( that is X = X-Y), then make Y = Y/2  (only take the integer part if it is not integer)
and put back Y to the list. We would like to know what is the minimum number of operations to make X into a non-positive integer.
If it is impossible to make X to non-positive, then output -1


( N<= 100,000  X<=1000000000 )

Input

Two integers in the first line X and N , in the following line, there are N integers which are the items in the list.

Output

one integer which is the minimum number of operations.

Sample Input Copy

21 7
1 9 8 2 3 3 -1

Sample Output Copy

3

Source/Category