import java.io.*;
import hsa.Console;
import java.util.Arrays;

// The "Time for Change" class.
public class Change
{
    public static void main (String[] args) throws IOException
    {

	// Open up the input and output file for IO purpose
	FileReader inFile = new FileReader ("DATA4.txt");
	FileWriter outFile = new FileWriter ("OUT4.txt");

	// Link the input and output file for
	BufferedReader in = new BufferedReader (inFile);
	BufferedWriter out = new BufferedWriter (outFile);

	String line;

	// Keep reading as long as not end of file (eof)
	while ((line = in.readLine ()) != null)
	{
	    int coinCount = 0;
	    String totaL = line;
	    int total = Integer.parseInt (totaL);
	    String counT = in.readLine ();
	    int count = Integer.parseInt (counT);
	    String[] Coins = new String [count];
	    int[] IntCoins = new int [count];
	    int[] num = new int [count];
	    int remainder;
	    for (int i = 0 ; i < count ; i++)
	    {
		Coins [i] = in.readLine ();
	    }
	    for (int i = 0 ; i < count ; i++)
	    {
		IntCoins [i] = Integer.parseInt (Coins [i]);
	    }
	    Arrays.sort (IntCoins);

	    int k = 0;

	    for (int j = count ; j > 0 ; j--)
	    {
		if (total % IntCoins [j - 1] != 0)
		{
		    coinCount = coinCount + (total / IntCoins [j - 1]);
		    total = total % IntCoins [j - 1];
		    continue;
		}
		else if (total % IntCoins [j - 1] == 0)
		{
		    coinCount += total / IntCoins [j - 1];
		    break;
		}
	    }
	    String countCoins = "" + coinCount;

	    out.write (countCoins);
	    out.newLine ();

	    out.flush ();

	}


	out.close ();


    } // main method
} // End of Class



