import sys
sys.setrecursionlimit(10 ** 6)
n , m = map(int,input().split())
coins = list(map(int,input().split()))
coins.sort(reverse=True)
dp = [[float("inf")]*(n + 1) for _ in range(m + 1)]
def solve(i , value):
    if dp[i][value] != float("inf"):
        return dp[i][value]
    if i == m - 1 or value == 0:
        ret_val = value
    elif coins[i] > value:
        ret_val = solve(i + 1,value)
    else:
        ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1)
    dp[i][value] = ret_val
    return ret_val

solve(0 , n)
print(dp[0][n]) import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 n , m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m coins = list(map(int,input().split())) coins list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split coins.sort(reverse=True) coins.sort coins sort reverse=True reverse True [float("inf")]*(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")]*(n + 1) [float("inf")] float("inf") float "inf" n + 1 n 1 dp = [[float("inf")]*(n + 1) for _ in range(m + 1)] dp [[float("inf")]*(n + 1) for _ in range(m + 1)] def solve(i , value):
    if dp[i][value] != float("inf"):
        return dp[i][value]
    if i == m - 1 or value == 0:
        ret_val = value
    elif coins[i] > value:
        ret_val = solve(i + 1,value)
    else:
        ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1)
    dp[i][value] = ret_val
    return ret_val solve if dp[i][value] != float("inf"):
        return dp[i][value]
     dp[i][value] != float("inf") dp[i][value] [i] dp i value float("inf") float "inf" return dp[i][value] dp[i][value] [i] dp i value if i == m - 1 or value == 0:
        ret_val = value
    elif coins[i] > value:
        ret_val = solve(i + 1,value)
    else:
        ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1)
     i == m - 1 or value == 0 i == m - 1 i m - 1 m 1 value == 0 value 0 ret_val = value ret_val value elif coins[i] > value:
        ret_val = solve(i + 1,value)
     coins[i] > value coins[i] coins i value ret_val = solve(i + 1,value) ret_val solve(i + 1,value) solve i + 1 i 1 value ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1) ret_val min(solve(i + 1,value) , solve(i,value - coins[i]) + 1) min solve(i + 1,value) solve i + 1 i 1 value solve(i,value - coins[i]) + 1 solve(i,value - coins[i]) solve i value - coins[i] value coins[i] coins i 1 dp[i][value] = ret_val dp[i][value] [i] dp i value ret_val return ret_val ret_val i i value value solve(0 , n) solve 0 n print(dp[0][n]) print dp[0][n] [0] dp 0 n m = map(int,input().split()) map(int,input().split()) m def solve(i , value):
    if dp[i][value] != float("inf"):
        return dp[i][value]
    if i == m - 1 or value == 0:
        ret_val = value
    elif coins[i] > value:
        ret_val = solve(i + 1,value)
    else:
        ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1)
    dp[i][value] = ret_val
    return ret_val def solve(i , value):
    if dp[i][value] != float("inf"):
        return dp[i][value]
    if i == m - 1 or value == 0:
        ret_val = value
    elif coins[i] > value:
        ret_val = solve(i + 1,value)
    else:
        ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1)
    dp[i][value] = ret_val
    return ret_val solve n , m = map(int,input().split()) map(int,input().split()) n dp = [[float("inf")]*(n + 1) for _ in range(m + 1)] [[float("inf")]*(n + 1) for _ in range(m + 1)] dp coins = list(map(int,input().split())) list(map(int,input().split())) coins
import sys
sys.setrecursionlimit(10 ** 6)
n , m = map(int,input().split())
coins = list(map(int,input().split()))
coins.sort(reverse=True)
dp = [[float("inf")]*(n + 1) for _ in range(m + 1)]
def solve(i , value):
    if dp[i][value] != float("inf"):
        return dp[i][value]
    if i == m - 1 or value == 0:
        ret_val = value
    elif coins[i] > value:
        ret_val = solve(i + 1,value)
    else:
        ret_val = min(solve(i + 1,value) , solve(i,value - coins[i]) + 1)
    dp[i][value] = ret_val
    return ret_val

solve(0 , n)
print(dp[0][n])
