import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) def sieve_of_eratosthenes(n): # n以下の素数の全列挙 prime_list = [] A = [1]*(n+1) # A[i] = iが素数なら1,その他は0 A[0] = A[1] = 0 for i in range(2,int(n**.5)+1): if A[i]: prime_list.append(i) for j in range(i**2,n+1,i): A[j] = 0 for i in range(int(n**.5)+1,n+1): if A[i] == 1: prime_list.append(i) return prime_list M,N = I(),I() C = LI() price = [-1]*(M+1) # price[i] = 最大何個のカップ麺でi円を実現できるか(できなければ-1) price[0] = 0 for i in range(1,M+1): for j in range(N): c = C[j] if i >= c and price[i-c] >= 0: price[i] = max(price[i],price[i-c]+1) prime_list = sieve_of_eratosthenes(M-1) ans = sum(price[M-p] for p in prime_list if price[M-p] >= 0) + M//min(C) print(ans)