Sieve

Time limit: 1s Memory limit: 128MB Input: Output:

Giorgio is playing with the Sieve of Eratosthenes, one of the most ancient algorithms of all times. This algorithm starts with a row of all numbers from 22 to MM, then repeatedly selects the smallest non-selected number remaining in the row, erasing every multiple of it. At the end of the process, only prime numbers will have survived in the row!

Giorgio is trying to apply a similar idea, but with few differences. Firstly, some numbers are missing from the starting row, which contains only NN numbers overall (each of them between 22 and MM), in increasing order. Secondly, every time Giorgio selects a number, he erases not only the multiples of it but also its divisors. As in the original algorithm, Giorgio keeps selecting numbers from the row (end erasing accordingly), stopping when every remaining number has been already selected; but he doesn't have to select numbers in increasing order. How many numbers can remain at the end of the process, at minimum?

Input data

The first line of the input contains NN and MM. The second line of the input contains the NN integers in increasing order.

Output data

The output file will contain a single line with an integer: the minimum amount of numbers that must remain at the end of the process.

Constraints and clarifications

  • 1N2501 \leq N \leq 250
  • 1M1061 \leq M \leq 10^6
  • For tests worth 3535 points, 1N91 \leq N \leq 9
  • For tests worth 1515 more points, 1M201 \leq M \leq 20
  • For tests worth 2020 more points, 1N501 \leq N \leq 50

Example 1

stdin

6 10
3 4 6 7 8 9

stdout

3

Explanation

In the first sample case, one of the best strategies is to choose numbers 77, 33 and 44. Suboptimal solutions exist, such as choosing numbers 99, 88, 77 and 66.

Example 2

stdin

6 20
2 5 7 10 14 20

stdout

2

Explanation

In the second sample case, one of the best strategies is to choose numbers 2020 and 1414.

Log in or sign up to be able to send submissions!