import java.util.Arrays;
import java.util.Scanner;

public class Yukicoder247 {

    int now;
    static boolean ok = false;
    static int min = 100000000;
    static int[] a;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        int n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        // ゴリ押し
        gorigori(n - 1, c, 0);
        System.out.println(min);
    }

    public static void gorigori(int now, int nokori, int num) {
        if ( now < 0) return;
        if (nokori % a[now] == 0) {
            min = Math.min(num + nokori / a[now], min);
            ok = true;
            return;
        }
        for (int i = nokori / a[now]; i >= 0; i--) {
            gorigori(now - 1, nokori - i * a[now], num + i);
        }
    }
}