Under construction

Still being built. Things may change

City of Lights

Interview

Time limit1sMemory limit512 MB

Summary
Given N lights initially on and k toggles where toggle i flips every multiple of i, find the maximum number of lights that are off at any point during the sequence.
Level

Medium4 of 10

Topics
Array, Implementation, Brute force, Simulation
Solved
No attempts yet

Problem

Paris has been called "ville lumière" (city of lights) since the 17th century. It earned this nickname in part because of the many city lights illuminating famous sites such as monuments, statues, churches, or fountains.

Those public lights in Paris are numbered from 1 to N and are all on by default. A group of hackers has gained the capability to toggle groups of lights. Every time the hackers use their program, they cause a number i (that they cannot control) to be sent to the system controlling the city lights. The lights numbered i, 2i, 3i, and so on (up to N) then change state instantly: lights that were on go off, and lights that were off go on.

During the night, the hackers use their programs k times. What is the greatest number of lights that are simultaneously off at the same time?

Input

The input comprises several lines, each consisting of a single integer:

  • The first line contains the number N of lights.
  • The second line contains the number k of uses hackers's program.
  • The next k lines contain a number i sent to the system controlling the lights.

Output

The output should consist of a single line, whose content is an integer, the greatest number of lights that are simultaneously off at the same time.

Constraints

  • 1 ≤ N ≤ 1 000 000;
  • 1 ≤ k ≤ 100;
  • 1 ≤ i ≤ N.

Examples1

  1. Example 1

    Input
    10
    4
    6
    2
    1
    3
    
    Expected output
    6