Sphere Online Judge

Computer geeks! Show off your skills and claim the job of your dreams! RecruitCoders.com

SPOJ Problem Set (classical)

6285. Another Game With Numbers

Problem code: NGM2

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
Languages:All except: PERL 6
Resource:-

hide comments
2012-05-14 20:42:02 Gunjit Agrawal
after running 23 test cases the judge says WA ... can any1 help me plz
2011-12-09 11:26:15 accept
can anybody help me about runtime error (SIGSEGV)
2011-07-31 09:51:36 sesume uchiha
@paranoid : can u help me with the test case for which my code is failing (id 5453378)

Last edit: 2011-07-31 10:28:10
2011-07-14 13:20:52 anubhav gupta
@paranoid please check solution id 5378282 its giving wa.dont know why
SPOJ System © 2012 Sphere Research Labs | Projekty informatyczne i aplikacje na zamówienie. All Rights Reserved.