N,x=map(int,input().split())
Children=list(map(int,input().split()))
Children.sort(key=lambda x:x)
n=0
S=0
while n<=N-1:
  S+=Children[n]
  if S<x:
    n+=1
  elif S==x:
    n+=1
    break
  elif S>x:
    break
if S<x:
  n=-1
print(n)