def main():
    N, x = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    ans = 0
    i = 0
    while x > 0:
        if i < N and x - a[i] >= 0:
            x -= a[i]
            ans += 1
        else:
            break
        i += 1
    print(ans)


if __name__ == '__main__':
    main()
