import sys

input = lambda :sys.stdin.readline().rstrip()



N, x = list(map(int, input().split()))

A = sorted(list(map(int, input().split())))



if x > sum(A):

  cnt = -1

else:

  cnt = 0

  

for i in range(N):

    if x - A[i] >= 0:

        cnt += 1

        x -= A[i]

    if x <= 0:

        break

    #print(cnt, x)



print(cnt)
n, x = list(map(int, input().split()))

A = sorted(list(map(int, input().split())))



if sum(A) < x:

    cnt = -1

else:

    cnt = 0

    

for a in A:

    x -= a

    if x >= 0:

        cnt += 1

    if x <= 0:

        print(cnt)

        exit()

print(cnt)
import sys

input = lambda: sys.stdin.readline().rstrip()
N, x = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
if x > sum(A):
    cnt = -1
else:
    cnt = 0
for i in range(N):
    if x - A[i] >= 0:
        cnt += 1
        x -= A[i]
    if x <= 0:
        break
    # print(cnt, x)
print(cnt)

n, x = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
if sum(A) < x:
    cnt = -1
else:
    cnt = 0
for a in A:
    x -= a
    if x >= 0:
        cnt += 1
    if x <= 0:
        print(cnt)
        exit()
print(cnt)

-import sys - -input = lambda: sys.stdin.readline().rstrip() -N, x = list(map(int, input().split())) +n, x = list(map(int, input().split())) -if x > sum(A): +if sum(A) < x: -for i in range(N): -    if x - A[i] >= 0: +for a in A: +    x -= a +    if x >= 0: -        x -= A[i] -        break -    # print(cnt, x) +        print(cnt) +        exit()