def get_number_of_coin(coins, dp_coin, total):
    for c in coins:
        for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
    return dp_coin[-1]


if __name__ == "__main__":
    total, n_coin = map(int, input().split())
    *coins, = map(int, input().split())    
    dp_coin = [10000] * (total + 1)
    dp_coin[0] = 0
    print(get_number_of_coin(coins, dp_coin, total)) def get_number_of_coin(coins, dp_coin, total):
    for c in coins:
        for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
    return dp_coin[-1] get_number_of_coin for c in coins:
        for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
     c coins for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
     j range(c, total + 1) range c total + 1 total 1 dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1) dp_coin[j] dp_coin j min(dp_coin[j], dp_coin[j - c] + 1) min dp_coin[j] dp_coin j dp_coin[j - c] + 1 dp_coin[j - c] dp_coin j - c j c 1 return dp_coin[-1] dp_coin[-1] dp_coin -1 coins coins dp_coin dp_coin total total if __name__ == "__main__":
    total, n_coin = map(int, input().split())
    *coins, = map(int, input().split())    
    dp_coin = [10000] * (total + 1)
    dp_coin[0] = 0
    print(get_number_of_coin(coins, dp_coin, total)) __name__ == "__main__" __name__ "__main__" total, n_coin = map(int, input().split()) total map(int, input().split()) map int input().split() ().split () input split n_coin *coins, = map(int, input().split()) *coins coins map(int, input().split()) map int input().split() ().split () input split dp_coin = [10000] * (total + 1) dp_coin [10000] * (total + 1) [10000] 10000 total + 1 total 1 dp_coin[0] = 0 dp_coin[0] dp_coin 0 0 print(get_number_of_coin(coins, dp_coin, total)) print get_number_of_coin(coins, dp_coin, total) get_number_of_coin coins dp_coin total total, n_coin = map(int, input().split()) map(int, input().split()) total dp_coin = [10000] * (total + 1) [10000] * (total + 1) dp_coin def get_number_of_coin(coins, dp_coin, total):
    for c in coins:
        for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
    return dp_coin[-1] def get_number_of_coin(coins, dp_coin, total):
    for c in coins:
        for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
    return dp_coin[-1] get_number_of_coin n_coin = map(int, input().split()) map(int, input().split()) n_coin
def get_number_of_coin(coins, dp_coin, total):
    for c in coins:
        for j in range(c, total + 1):
            dp_coin[j] = min(dp_coin[j], dp_coin[j - c] + 1)
    return dp_coin[-1]


if __name__ == "__main__":
    total, n_coin = map(int, input().split())
    *coins, = map(int, input().split())    
    dp_coin = [10000] * (total + 1)
    dp_coin[0] = 0
    print(get_number_of_coin(coins, dp_coin, total))
