N,M = map(int,input().split()) C = list(map(int,input().split())) C.sort() now = 0 while M-C[now]>= 0: M -= C[now] now += 1 print(now)