import sys
input = sys.stdin.readline

n, m = map(int,input().split())
c = [0] + list(map(int,input().split()))

dp = [[0] + [n+1 for _ in range(n)] for _ in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if j >=c[i]:
            dp[i][j] = min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j] = dp[i-1][j]

print (dp[m][n]) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m c = [0] + list(map(int,input().split())) c [0] + list(map(int,input().split())) [0] 0 list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split [0] + [n+1 for _ in range(n)] for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [0] + [n+1 for _ in range(n)] [0] 0 [n+1 for _ in range(n)] dp = [[0] + [n+1 for _ in range(n)] for _ in range(m+1)] dp [[0] + [n+1 for _ in range(n)] for _ in range(m+1)] for i in range(1,m+1):
    for j in range(1,n+1):
        if j >=c[i]:
            dp[i][j] = min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j] = dp[i-1][j] i range(1,m+1) range 1 m+1 m 1 for j in range(1,n+1):
        if j >=c[i]:
            dp[i][j] = min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j] = dp[i-1][j] j range(1,n+1) range 1 n+1 n 1 if j >=c[i]:
            dp[i][j] = min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j] = dp[i-1][j] j >=c[i] j c[i] c i dp[i][j] = min(dp[i-1][j],dp[i][j-c[i]]+1) dp[i][j] [i] dp i j min(dp[i-1][j],dp[i][j-c[i]]+1) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j-c[i]]+1 dp[i][j-c[i]] [i] dp i j-c[i] j c[i] c i 1 dp[i][j] = dp[i-1][j] dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j print (dp[m][n]) print dp[m][n] [m] dp m n m = map(int,input().split()) map(int,input().split()) m c = [0] + list(map(int,input().split())) [0] + list(map(int,input().split())) c n, m = map(int,input().split()) map(int,input().split()) n input = sys.stdin.readline sys.stdin.readline input dp = [[0] + [n+1 for _ in range(n)] for _ in range(m+1)] [[0] + [n+1 for _ in range(n)] for _ in range(m+1)] dp
import sys
input = sys.stdin.readline

n, m = map(int,input().split())
c = [0] + list(map(int,input().split()))

dp = [[0] + [n+1 for _ in range(n)] for _ in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if j >=c[i]:
            dp[i][j] = min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j] = dp[i-1][j]

print (dp[m][n])
