def calc_number_of_coin(sum, coins):
    dp = [999999999]*(sum+1)
    dp[0] = 0
    for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
    return dp[sum]



if __name__ == '__main__':
    # ??????????????\???
    # f = open('input.txt')
    # sum, _ = [int(x) for x in f.readline().strip().split(' ')]
    # coins = [int(x) for x in f.readline().strip().split(' ')]

    sum, _ = [int(x) for x in input().strip().split(' ')]
    coins = [int(x) for x in input().strip().split(' ')]

    # ???????????????
    result = calc_number_of_coin(sum, coins)

    # ???????????¨???
    print(result) def calc_number_of_coin(sum, coins):
    dp = [999999999]*(sum+1)
    dp[0] = 0
    for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
    return dp[sum] calc_number_of_coin dp = [999999999]*(sum+1) dp [999999999]*(sum+1) [999999999] 999999999 sum+1 sum 1 dp[0] = 0 dp[0] dp 0 0 for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
     i range(len(coins)) range len(coins) len coins for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
     j range(coins[i], sum+1) range coins[i] coins i sum+1 sum 1 dp[j] = min(dp[j], dp[j-coins[i]]+1) dp[j] dp j min(dp[j], dp[j-coins[i]]+1) min dp[j] dp j dp[j-coins[i]]+1 dp[j-coins[i]] dp j-coins[i] j coins[i] coins i 1 return dp[sum] dp[sum] dp sum sum sum coins coins if __name__ == '__main__':
    # ??????????????\???
    # f = open('input.txt')
    # sum, _ = [int(x) for x in f.readline().strip().split(' ')]
    # coins = [int(x) for x in f.readline().strip().split(' ')]

    sum, _ = [int(x) for x in input().strip().split(' ')]
    coins = [int(x) for x in input().strip().split(' ')]

    # ???????????????
    result = calc_number_of_coin(sum, coins)

    # ???????????¨???
    print(result) __name__ == '__main__' __name__ '__main__' int(x) for x in input().strip().split(' ') for x in input().strip().split(' ') x input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' for x in input().strip().split(' ') int(x) int x sum, _ = [int(x) for x in input().strip().split(' ')] sum [int(x) for x in input().strip().split(' ')] _ int(x) for x in input().strip().split(' ') for x in input().strip().split(' ') x input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' for x in input().strip().split(' ') int(x) int x coins = [int(x) for x in input().strip().split(' ')] coins [int(x) for x in input().strip().split(' ')] result = calc_number_of_coin(sum, coins) result calc_number_of_coin(sum, coins) calc_number_of_coin sum coins print(result) print result def calc_number_of_coin(sum, coins):
    dp = [999999999]*(sum+1)
    dp[0] = 0
    for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
    return dp[sum] def calc_number_of_coin(sum, coins):
    dp = [999999999]*(sum+1)
    dp[0] = 0
    for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
    return dp[sum] calc_number_of_coin _ = [int(x) for x in input().strip().split(' ')] [int(x) for x in input().strip().split(' ')] _ coins = [int(x) for x in input().strip().split(' ')] [int(x) for x in input().strip().split(' ')] coins sum, _ = [int(x) for x in input().strip().split(' ')] [int(x) for x in input().strip().split(' ')] sum result = calc_number_of_coin(sum, coins) calc_number_of_coin(sum, coins) result
def calc_number_of_coin(sum, coins):
    dp = [999999999]*(sum+1)
    dp[0] = 0
    for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
    return dp[sum]



if __name__ == '__main__':
    # ??????????????\???
    # f = open('input.txt')
    # sum, _ = [int(x) for x in f.readline().strip().split(' ')]
    # coins = [int(x) for x in f.readline().strip().split(' ')]

    sum, _ = [int(x) for x in input().strip().split(' ')]
    coins = [int(x) for x in input().strip().split(' ')]

    # ???????????????
    result = calc_number_of_coin(sum, coins)

    # ???????????¨???
    print(result)