NGM2 - Another Game With Numbers

Little Chikoo likes to play with numbers. Often he plays the following game:

  1. He chooses a number N and a set of positive integers.
  2. He writes down all the numbers from 1 to N.
  3. He chooses the first number (say x) from the set and cancels out all the multiples of x from 1 to N, including x.
  4. He repeats step 3 for all the numbers from the set.

One day Little Chikoo was in a mood to play pranks. So his brother asked him to play the game with a certain challenge. He made the game a little harder and asked him to find out the number of integers which aren't cancelled after he completes step 4. If he does that then Little Chikoo gets to play on his brother's Nintendo for one full day. Now Little Chikoo is in a hurry and wants to finish the job as soon as possible. He has asked for your help.

Input

The first line of the input contains N and K. (N <= 10^9, K <= 15)

Then K numbers follow all in a single line. All numbers are <= 100.

Output

The output file must contain the number of integers that aren't cancelled after he finishes step 4 of the game.

Example

Input:
10 3
2 4 5

Output:
4

(The numbers 1, 3, 7 and 9 weren't cancelled).


Added by:Paranoid Android
Date:2010-03-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 VB.NET
Resource:-

hide comments
2016-09-13 10:06:17
AC in one go :D
2016-09-05 10:53:40 Bhumit
@Paranoid Android
Can you please tell why I am getting NZEC in Java??
Submission ID - 17652754
2016-06-13 08:09:05 [Mayank Pratap]
WA on 21 .. any help ??
2016-02-01 17:05:54 kejriwal
AC in one go :) !!!
same algorithm in python giving NZEC/TLE/WA xP
@author can you tell me the glitch !

Last edit: 2016-02-02 17:50:24
2016-01-20 16:51:34 GAURAV CHANDEL
Nice problem...
2015-09-06 18:38:32
TLE in 25th test case
2015-01-07 06:46:18 sancha
g++ 4.3.2 gives this error "Language available only on Cube Cluster"
2014-11-18 12:17:26 ayushi agarwal
got the problem i was using int instead of long long
2014-11-18 11:58:18 ayushi agarwal
wrong answer on run 25. can anyone tell why?
2014-09-05 13:19:32 Praneeth Reddy
getting WA at 25....what is happening???
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.