m = int(input()) n = int(input()) c = list(map(int,input().split())) c.sort(reverse=True) prime = [] table = [True] * (m + 1) table[0] = table[1] = False for i in range(2, m + 1): if not table[i]: continue k = i + i while k < m + 1: table[k] = False k += i prime.append(i) divp = [False] * 10001 divpnum = [] for i in range(len(prime)): divp[m - prime[i]] = True divpnum.append(m - prime[i]) cost = [-1] * 20001 cost[0] = 0 for i in range(20001): for C in c: if cost[i] >= 0 and i + C <= m: cost[i + C] = max(cost[i] + 1, cost[i + C]) ans = 0 for i in divpnum: if cost[i] >= 0: ans += cost[i] ans += m // c[-1] print(ans)