import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

class Change {
	static int count;
	static int[] counts = new int[0];

	public static void main(String args[]) throws IOException {
		int amount, i, j, k, c;
		int[] coins;
	
		BufferedReader in = new BufferedReader(new FileReader("DATA4.txt"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("OUT4.txt")));
		
		String line = in.readLine();
		
		while (line != null) {
			if (!line.equals("")) {
				amount = Integer.parseInt(line);
				coins = new int[Integer.parseInt(in.readLine())];
				for (i = 0; i < coins.length; i++) {
					c = Integer.parseInt(in.readLine());
					for (j = i - 1; j >= 0; j--) {
						if (coins[j] > c)
							break;
					}
					
					j++;	
					for (k = i; k > j; k--) {
						coins[k] = coins[k - 1];
					}
					
					coins[j] = c;
				}
				
				count = 0;
				countCoins(amount, coins, 0);
				c = counts[0];
				for (i = 1; i < counts.length; i++) {
					if (counts[i] < c)
						c = counts[i];
				}
				counts = new int[0];
				
				out.println(c);
				
			}
			line = in.readLine();
		}
		in.close();
		out.close();
	}
	
	private	static void printArray(int[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();	
	}
	
	private static void add() {
		int[] temp = new int[counts.length + 1];
		int i;
		for (i = 0; i < counts.length; i++) {
			temp[i] = counts[i];
		}
		temp[i] = count;
		counts = temp;
	}
	
	private static void countCoins(int amount, int[] coins, int i) {
		count++;
		for (; i < coins.length; i++) {
			if (coins[i] < amount) {
				countCoins(amount - coins[i], coins, i);
			} else if (coins[i] == amount) {
				add();
			}
		}
		count--;
	}
}

