package main

import (
  "fmt"
  "sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	count := 0
	for i := 0; i < n; i++ {
		if a[i] <= x {
			x -= a[i]
			count++
		} else {
			break
		}
	}
	fmt.Println(count)

}