N,M = map(int, input().split()) C = sorted(list(map(int, input().split()))) cnt = 0 for c in C: if c > M: break M -= c cnt += 1 print(cnt)