def main():

    N, x = list(map(int, input().split()))
    a = list(map(int, input().split()))
 
    b = sorted(a)
 
    ans = 0
    total = 0
 
    for i in range(len(b)):
        if total + b[i] <= x:
            ans += 1
            total += b[i]


    print(ans)


if __name__ == "__main__":
    main()