def prime(n): l = [2, 3] if n < 5 : return l for i in range(5, n+1, 2): if sum([1 for x in l if i % x]): l += [i] return l M = int(input()) N = int(input()) C = list(map(int, input().split())) p = set(prime(M)) ans = M // min(C) q = [0] cnt = 0 d = {} while q: cnt += 1 l = [] for i in set(q): for j in C: a = i + j if a <= M: l += [a] if M - a in p: d[M - a] = cnt q = l for i in d.values(): ans += i print(ans)