This page is still under construction.

Parts of this page are still being built. What you see may change.

Minho's number game

Time limit2sMemory limit512 MB

Summary
Count integers from 1 to N divisible by at least one of up to 20 given numbers, where duplicates and multiples make plain unions invalid.
Level

Medium7 of 10

Topics
Combinatorics, Number theory, Math, Bit manipulation
Solved
No attempts yet

Problem

Minho has KK cards. Each card has one positive integer written on it. Minho made up a number game with them.

The game is to count how many positive integers from 1 to NN are divisible by at least one of the numbers written on the cards.

There are far too many numbers to count by hand. Count them for Minho.

Input

The first line contains NN and KK, separated by a space. (1≤N≤1091 \le N \le 10^9, 1≤K≤201 \le K \le 20)

The second line contains the numbers written on the cards, A1,A2,…,AKA_1, A_2, \dots, A_K, in order and separated by spaces. (1≤Ai≤1091 \le A_i \le 10^9)

Several cards may carry the same number.

Output

Print on one line how many positive integers from 1 to NN are divisible by at least one of the numbers written on the cards.

Examples2

  1. Example 1

    Input
    100 2
    2 3
    
    Expected output
    67
    
  2. Example 2

    Input
    100 3
    2 3 7
    
    Expected output
    72