# -*- coding: utf-8 -*- def main(): a = int(input()) b = int(input()) c = [int(x) for x in input().split()] c.sort() y = [] for i in c: if sum(y)+i < a: y.append(int(i)) sum(y) else: ans = len(y) if ans > b: print("error") else: print(ans) pass if __name__ == "__main__": main()