# -*- coding: utf-8 -*- N, M = map(int, raw_input().split()) C = map(int, raw_input().split()) C.sort() tot = 0 cnt = 0 while tot < M and cnt != N: tot += C[cnt] cnt += 1 if M == tot: print cnt else: print cnt - 1