def func(a, m, n):
cur, count, i = 0, 0, 0
if a[0] != 1:
return -1
else:
while cur < m:
while i + 1 < n and a[i + 1] <= cur + 1:
i += 1
cur += a[i]
count += 1
return count
m, n = map(int, input().split())
a = []
for i in range(n):
a.append(int(input()))
a.sort()
num = func(a, m, n)
print(num)