#!/usr/bin/env pypy3 import array import itertools IMPOSSIBLE = -1 INF = 10 ** 6 def compute_min(c, n, bs): dp = array.array("L", (INF for _ in range(c + 1))) dp[0] = 0 for i, b in itertools.product(range(1, c + 1), bs): if b <= i: dp[i] = min(dp[i], dp[i - b] + 1) return dp[c] if dp[c] < INF else IMPOSSIBLE def main(): c = int(input()) n = int(input()) bs = array.array("L", map(int, input().split())) print(compute_min(c, n, bs)) if __name__ == '__main__': main()