# coding: utf-8 n,m = map(int, input().split(" ")) candys = list(map(int,input().split(" "))) candys = sorted(candys) res = 0 for i in range(n): m -= candys[i] if m <= 0: res = i+1 break print(res)