


N,M = map(int, input().split())
C = list(map(int, input().split()))

C.sort()
dp = [[float("inf") for _ in range(N+1)] for _ in range(M+1)]
dp[0][0] = 0


#i番目までのコインを使えるときに、j円を作る場合の、コインの最小枚数を求める
for i in range(M):
    for j in range(N+1):
        # i番目を使えない場合
        if C[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1)

print(dp[-1][-1]) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split C.sort() C.sort C sort [float("inf") for _ in range(N+1)] for _ in range(M+1) for _ in range(M+1) _ range(M+1) range M+1 M 1 for _ in range(M+1) [float("inf") for _ in range(N+1)] dp = [[float("inf") for _ in range(N+1)] for _ in range(M+1)] dp [[float("inf") for _ in range(N+1)] for _ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    for j in range(N+1):
        # i番目を使えない場合
        if C[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1) i range(M) range M for j in range(N+1):
        # i番目を使えない場合
        if C[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1) j range(N+1) range N+1 N 1 if C[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1) C[i] > j C[i] C i j dp[i+1][j] = dp[i][j] dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i][j], dp[i+1][j - C[i]] + 1) min dp[i][j] [i] dp i j dp[i+1][j - C[i]] + 1 dp[i+1][j - C[i]] [i+1] dp i+1 i 1 j - C[i] j C[i] C i 1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 dp = [[float("inf") for _ in range(N+1)] for _ in range(M+1)] [[float("inf") for _ in range(N+1)] for _ in range(M+1)] dp C = list(map(int, input().split())) list(map(int, input().split())) C N,M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M



N,M = map(int, input().split())
C = list(map(int, input().split()))

C.sort()
dp = [[float("inf") for _ in range(N+1)] for _ in range(M+1)]
dp[0][0] = 0


#i番目までのコインを使えるときに、j円を作る場合の、コインの最小枚数を求める
for i in range(M):
    for j in range(N+1):
        # i番目を使えない場合
        if C[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1)

print(dp[-1][-1])
