import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	auto nm = readln.split.map!(to!int);
	auto co = readln.split.map!(to!int);
	auto dp = new int[](nm[0] + 1);
	dp[] = int.max;
	foreach (c; co) {
		if (c > nm[0]) continue;
		dp[c] = 1;
	}
	foreach (i; 1..nm[0]) {
		foreach (c; co) {
			if (i+c > nm[0]) continue;
			dp[i+c] = min(dp[i+c], dp[i]+1);
		}
	}
	dp[nm[0]].writeln;
	
}