import java.io.*;
import java.util.Arrays;
import java.util.Scanner;


public class foreignCoins {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// File to read
		Scanner sc = new Scanner(new FileReader("data4.txt"));
		PrintWriter pw = new PrintWriter(new FileWriter("out4.txt"));
		
		for (int k=0; k<5; k++)
		{
			int change = sc.nextInt();
			int numCoins = sc.nextInt();
			int coins[] = new int[numCoins];
			for (int i=0; i<numCoins; i++)
			{
				coins[i] = sc.nextInt();
			}
			Arrays.sort(coins);
						
			// Now to make the change (greedy)
			
			int numEach[] = new int[numCoins];
			/*
			int j = numCoins-1;
			while ((change > 0) )
			{
				if (change >= coins[j])
				{
					numEach[j]++;
					change -= coins[j];
				} else {
					j--;
				}
			}
			*/
			
			// Make change recursively
			int total = makeChange(change, coins, coins.length-1);
			
			// Print out the coins
			//System.out.println(total);
			pw.println(total);
		}
		pw.close();
	}

	private static int makeChange(int change, int[] coins, int i) {
		int minCoin = -1;
		// Base case
		if (change == 0)
		{
			minCoin = 0;
		} else if (i >= 0) {
			int maxThisCoin = change / coins[i];
			for (int j = maxThisCoin; j>=0; j--)
			{
				int tryThis = makeChange(change-j*coins[i], coins, i-1);
				if ( (tryThis != -1) &&  ( (minCoin == -1) || ((tryThis+j) < minCoin) ) )
				{
					minCoin = tryThis+j;
				}
			}
		}
		return minCoin;
	}

}

