

def main()->None:
    (N, x) = map(int, input().split())
    a = list(map(int, input().split()))
    sorted_a = sorted(a) # 小さい順にならべる
    count = 0
    for i in sorted(a):
        x -= i
        if x < 0:
            break
        count += 1
    if count < N:print(count)
    else: print(N-1)


if __name__ == "__main__":
    main()