n, m = map(int, input().split(' ')) c_lst = sorted(list(map(int, input().split(' '))),reverse=False) empty_cnt = 0 get_num = 0 for c in c_lst: if get_num + c > m: break elif get_num + c == m: empty_cnt += 1 break else: get_num += c empty_cnt += 1 print(empty_cnt)