About lights
There are N lights, which are numbered from 1 to N. Every light turned off initially.
There is a sequence of linear inversions of this lights.Under the linear inversion means the inversion of every P-th light.For example, if P = 3, the inversion will occur on 3rd, 6th, 9th, etc. lights.
Determine, how many lights remain turned on after all the defined linear inversions.
InputFirst line consist of two integers - N and K - the number of lights and the number of linear inversions.Second line consists of K integers Pi, which specify period of inversions. (1 <= N <= 1000000000, 1 <= K <= 100, 1 <= Pi <= 50)
OutputOutput the number of lights, remained turned on.
Input:
Output:
20 3
2 3 8Output:
8 Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.