#!/usr/bin/env python3 from functools import lru_cache @lru_cache(maxsize=None) def box_in(L, W): W = list(W) for w in W: if w > L: W.remove(w) if len(W) == 0: return 0 candidate = [] for w in W: Wtmp = list(W) Wtmp.remove(w) candidate.append(box_in(L - w, tuple(Wtmp))) if len(candidate) == 0: return 1 return max(candidate) + 1 L = int(input()) N = int(input()) W = sorted(map(int, input().split())) print(box_in(L, tuple(W)))