def main():

    n, x = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    if a[0] > x:
        print(0)
        exit()
    elif sum(a) == x:
        print(n)
        exit()
    ans = 0
    for i in range(n):
        if x >= a[i]:
            x -= a[i]
            ans += 1
        else:
            break
    if x != 0:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()
