N, M = map(int, raw_input().split()) candy = map(int, raw_input().split()) candy.sort() cnt = 0 while(True): if M < candy[0]: break M -= candy.pop(0) cnt += 1 print cnt