def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    for i in range(N):
        x -= a[i]
        if x < 0:
            break
    ans = i
    print(ans)

if __name__ == "__main__":
    main()
