# yukicoder No.156 キャンディー・ボックス N, M = map(int, input().split()) C = [int(x) for x in input().split()] C.sort() empty = 0 for x in C: M -= x if M < 0: break empty += 1 print(empty)