시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 0 0 0 0.000%

문제

Frodo is fighting with the monster, whose heads are numbered sequentially from 1 to K. Monster is cybernetic genome carrier and it’s characterised with unusual properties. 

If Frodo cuts a head with an odd number X, then Y new heads will appear on this place, where Y is the maximal prime number less than X. If Frodo cuts the first head, no new head will appear. It’s known, that the monster’s neck can not accommodate more than 30000000 heads (it means, that if sum of Y and the count of remaining heads is greater than 30 000 000, then the count of heads will be exactly 30000000). 

If Frodo cuts a head with an even number Z, the monster will lose all heads with numbers containing the same number of ones in binary notation as Z. If monster loses all heads, then the fight ends. 

After each Frodo’s strike (after appearance of new heads as well as after losing of some heads) monster’s heads are renumbered starting with 1. 

Frodo doesn’t have time to examine whether numbers of monster’s heads are odd or even and he cuts them unsystematically. Fortunately, he has modern laser sword which memorises numbers of cut heads in the moment of the cut. 

The fight was finished in the evening, but tired Frodo cannot count the heads left. 

You need to write a program which counts the number of heads after the fight is finished. 

입력

In the first line of the input file there are two space separated integer numbers K (2 ≤ K ≤ 30000000) and N (2 ≤ N ≤ 200000), where K is the initial count of monster heads, and N is the number of cuts. Each of the next N lines contains an integer number. These numbers describe the sequence of cutting heads. Head numbers are correct, i. e. they never exceed the total count of monster heads at the moment of the strike. 

출력

Write to the output file the count of heads left on the monster’s neck after the fight is finished. 

예제 입력

7 4
5
9
6
4

예제 출력

5

힌트

After cutting 5th head, 3 new heads will appear and the total number becomes 9. After cutting 9th head, 7 new heads will appear and the total number becomes 15. After cutting 6th head, monster will also lose heads with numbers 3, 5, 9, 10, 12. And after cutting 4th head, it will lose heads 8, 2, 1. After the fight monster will have 5 heads left.