#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
15 6
1 2 7 8 12 50

output:
2
"""

import sys


def solve():
    rec[0] = 0
    for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

    return rec


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    total_cost, c_num = map(int, _input[0].split())
    coins = list(map(int, _input[1].split()))
    # assert len(coins) == c_num
    rec = [float('inf')] * (total_cost + 1)
    ans = solve()
    print(ans[-1]) """
input:
15 6
1 2 7 8 12 50

output:
2
""" import sys sys def solve():
    rec[0] = 0
    for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

    return rec solve rec[0] = 0 rec[0] rec 0 0 for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

     coin coins for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

     current_cost range(coin, total_cost + 1) range coin total_cost + 1 total_cost 1 rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1) rec[current_cost] rec current_cost min(rec[current_cost], rec[current_cost - coin * 1] + 1) min rec[current_cost] rec current_cost rec[current_cost - coin * 1] + 1 rec[current_cost - coin * 1] rec current_cost - coin * 1 current_cost coin * 1 coin 1 1 return rec rec if __name__ == '__main__':
    _input = sys.stdin.readlines()
    total_cost, c_num = map(int, _input[0].split())
    coins = list(map(int, _input[1].split()))
    # assert len(coins) == c_num
    rec = [float('inf')] * (total_cost + 1)
    ans = solve()
    print(ans[-1]) __name__ == '__main__' __name__ '__main__' _input = sys.stdin.readlines() _input sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines total_cost, c_num = map(int, _input[0].split()) total_cost map(int, _input[0].split()) map int _input[0].split() [0].split [0] _input 0 split c_num coins = list(map(int, _input[1].split())) coins list(map(int, _input[1].split())) list map(int, _input[1].split()) map int _input[1].split() [1].split [1] _input 1 split rec = [float('inf')] * (total_cost + 1) rec [float('inf')] * (total_cost + 1) [float('inf')] float('inf') float 'inf' total_cost + 1 total_cost 1 ans = solve() ans solve() solve print(ans[-1]) print ans[-1] ans -1 _input = sys.stdin.readlines() sys.stdin.readlines() _input total_cost, c_num = map(int, _input[0].split()) map(int, _input[0].split()) total_cost rec = [float('inf')] * (total_cost + 1) [float('inf')] * (total_cost + 1) rec c_num = map(int, _input[0].split()) map(int, _input[0].split()) c_num ans = solve() solve() ans coins = list(map(int, _input[1].split())) list(map(int, _input[1].split())) coins def solve():
    rec[0] = 0
    for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

    return rec def solve():
    rec[0] = 0
    for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

    return rec solve
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
15 6
1 2 7 8 12 50

output:
2
"""

import sys


def solve():
    rec[0] = 0
    for coin in coins:
        for current_cost in range(coin, total_cost + 1):
            rec[current_cost] = min(rec[current_cost], rec[current_cost - coin * 1] + 1)

    return rec


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    total_cost, c_num = map(int, _input[0].split())
    coins = list(map(int, _input[1].split()))
    # assert len(coins) == c_num
    rec = [float('inf')] * (total_cost + 1)
    ans = solve()
    print(ans[-1])