if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    c = sorted(c)

    dp = [[0] * (n + 1)] * m

    for i in range(n + 1):
        dp[0][i] = i
    
    for i in range(1, m):
        for j in range(n + 1):
            dp[i][j] = dp[i - 1][j]
            if j - c[i] >= 0:
                dp[i][j] = min(dp[i][j], dp[i][j - c[i]] + 1)
    print(dp[m-1][n])
         if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    c = sorted(c)

    dp = [[0] * (n + 1)] * m

    for i in range(n + 1):
        dp[0][i] = i
    
    for i in range(1, m):
        for j in range(n + 1):
            dp[i][j] = dp[i - 1][j]
            if j - c[i] >= 0:
                dp[i][j] = min(dp[i][j], dp[i][j - c[i]] + 1)
    print(dp[m-1][n])
         __name__ == "__main__" __name__ "__main__" 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 = sorted(c) c sorted(c) sorted c dp = [[0] * (n + 1)] * m dp [[0] * (n + 1)] * m [[0] * (n + 1)] [0] * (n + 1) [0] 0 n + 1 n 1 m for i in range(n + 1):
        dp[0][i] = i
    
     i range(n + 1) range n + 1 n 1 dp[0][i] = i dp[0][i] [0] dp 0 i i for i in range(1, m):
        for j in range(n + 1):
            dp[i][j] = dp[i - 1][j]
            if j - c[i] >= 0:
                dp[i][j] = min(dp[i][j], dp[i][j - c[i]] + 1)
     i range(1, m) range 1 m for j in range(n + 1):
            dp[i][j] = dp[i - 1][j]
            if j - c[i] >= 0:
                dp[i][j] = min(dp[i][j], dp[i][j - c[i]] + 1)
     j range(n + 1) range n + 1 n 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 if j - c[i] >= 0:
                dp[i][j] = min(dp[i][j], dp[i][j - c[i]] + 1)
     j - c[i] >= 0 j - c[i] j c[i] c i 0 dp[i][j] = min(dp[i][j], dp[i][j - c[i]] + 1) dp[i][j] [i] dp i j min(dp[i][j], dp[i][j - c[i]] + 1) min dp[i][j] [i] dp i j dp[i][j - c[i]] + 1 dp[i][j - c[i]] [i] dp i j - c[i] j c[i] c i 1 print(dp[m-1][n]) print dp[m-1][n] [m-1] dp m-1 m 1 n c = sorted(c) sorted(c) c c = list(map(int, input().split())) list(map(int, input().split())) c m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n dp = [[0] * (n + 1)] * m [[0] * (n + 1)] * m dp
if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    c = sorted(c)

    dp = [[0] * (n + 1)] * m

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