def main():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    dp = [[10 ** 5 for i in range(n + 1)] for j in range(m + 1)]
    for i in range(m+1):
        dp[i][0] = 0
    for i in range(1, m+1):
        for j in range(1, n+1):
            if c[i - 1] <= j:
                dp[i][j] = min(dp[i][j - c[i - 1]] + 1, dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
    print(dp[-1][-1])


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


if __name__ == '__main__':
    main()

