import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
immutable int inf = mod;

void main(){
    int n, m;
    readVars(n, m);
    auto c = readln.split.to!(int[]);
    c.sort();

    auto dp = new int[](n + 1);
    dp[] = inf;
    dp[0] = 0;

    foreach(i ; 1 .. n + 1){
        foreach(cj ; c){
            if (i - cj < 0) break;

            dp[i] = min(dp[i], dp[i - cj] + 1);
        }
    }

    writeln(dp[n]);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}