## Starks Affair

Time Limit: 1 sec
Memory Limit: 256 MB
Attempts: 0
Accuracy: 0.00%
Author: Akashdeep Goel

Lord Eddard Stark has to leave his wife Catelyn Stark to help assist King Robert. Catelyn is very upset because of this move of Eddard. So to make up for Catelyn and to keep her busy he gives Catelyn an array of 0s and 1s.The number of ones in the array is always even. He tells her that she can transform the array by taking two bits b1,b2 from any 2 random locations (i,j) with difference in indexes of 3,5 or 7 ( ie. | i-j | = {3 or 5 or 7}) and do the following operations-

1.If one of the bit is 1 and other 0 She can swap them.

2. If both the bits are one both can be made 0.

After the return of Eddard from the Kings Landing Catelyn has to tell him the number of minimum moves required to reduce all the bits to 0s.If it is not possible, print -1.

Input-

The first line of input gives two numbers: n, number of bits in the array and m, the number of ones in the given array.The second line gives the indexes of the â€˜mâ€™ ones in the array.

Indexing is 0 based ( 0 to n-1 ).

Output-

one line containing minimum operations if its possible else print -1

Constraints-

2 <= n <= 1000

2 <= m <= 16

m is always even

Example-

Input 1-

4 2

0 3

Output-

1

Input 2-

4 2

0 2

Output 2-

-1

ID

SUBMITTED AT

STATUS

LANGUAGE

TIME

MEMORY USED

USER

TIME

STATUS

LANGUAGE

TIME

MEMORY USED