import java.util.Scanner; public class No5 { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int L = scan.nextInt(); int N = scan.nextInt(); int[] m = new int[L+1]; m[0] = 1; for (int i = 1; i < L+1; m[i] = 0, i++); int w, ans = 0; for (int i = 0; i < N; i++) { w = scan.nextInt(); for (int j = L-w; j >= 0; j--) { if (j+w < L+1 && m[j+w] < m[j]+1) m[j+w] = m[j]+1; } } for (int i = L; i >= 0; i--) { if (ans < m[i]) ans = m[i]; } System.out.println(ans-1); return; } }