input_list = list(map(int,input().split())) c_list = list(map(int,input().split())) n = input_list[0] m = input_list[1] sorted_c = sorted(c_list) store_c = [0] * (len(c_list) + 1) box = 0 for i in range(len(store_c)): if i == 0: store_c[i] = 0 else: store_c[i] = store_c[i-1] + sorted_c[i-1] for i in range(len(store_c)): if i == 0: continue if store_c[i] > m: break else: box += 1 res = box print(res)