package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, x int
    fmt.Scan(&n, &x)
    nums := make([]int,n);
    for i := 0; i < n; i++ {
    	fmt.Scan(&nums[i])
    }
    sort.Ints(nums)

    ans := 0

    for i := 0; i < n && 0<x; i++ {
    	x-=nums[i]
    	if x>=0 {
    		ans++
    	} else {
	    	break
    	}

    	if x==0 {
    		break
    	}
    }
	fmt.Println(ans)
}