function main(_stdin) {
    const stdin = _stdin.split('\n').filter(e => e.length);
    const [price, length] = stdin.shift().split(' ').map(Number);
    const coins = stdin.shift().split(' ').map(Number);

    const table = [];
    table[0] = 0;

    for(let i = 0; i<= length;i++){
        for (let j = coins[i]; j<= price; j++){
            table[j] = table[j] ? Math.min(table[j], table[j - coins[i]] + 1) : j / coins[i];
        }
    }

    console.log(table[price]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

