max = int(input()) num = int(input()) a = [input() for i in range(max)] a = a.sort() total[0] = a[0] for i in range(a): total[i + 1] = total[i] + a[i + 1] if max > total[0]: print('0') elif max == total[0]: print('1') elif max < total[i]: print(i)