package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strconv"
)

var input *bufio.Scanner = bufio.NewScanner(os.Stdin)

type IntSlice []int

func (intSlice IntSlice) String() string {
	var str string
	for _, val := range intSlice {
		str += fmt.Sprint(val," ")
	}
	return str
}

func (intSlice IntSlice) Get(index int) int {
	var num int
	num = intSlice[index]
	return num
}

func (intSlice IntSlice) Remove(index int) IntSlice {
	copy(intSlice[index:], intSlice[index+1:])
	return intSlice[:len(intSlice)-1]
}

func (intSlice IntSlice) AsValue() IntSlice {
	var slice IntSlice
	for _, val := range intSlice {
		slice = append(slice, val)
	}
	return slice
}

func (intSlice IntSlice) Mapping(f func(num int) string) []string {
	var stringSlice []string
	for _, val := range intSlice {
		stringSlice = append(stringSlice, f(val))
	}
	return stringSlice
}

func (intSlice IntSlice) Filter(f func(num int) bool) IntSlice {
	var slice IntSlice
	for _, val := range intSlice {
		if f(val) {
			slice = append(slice, val)
		}
	}
	return slice
}

func (intSlice IntSlice) Single(f func(num int) bool) IntSlice {
	count := len(intSlice.Filter(f))
	if count != 1 {
		panic("IllegalArgumentException: Collection contains more than one matching element.")
	}
	return intSlice
}

func (intSlice IntSlice) Max() int {
	var m int
	for _, val := range intSlice {
		m = int(math.Max(float64(val),float64(m)))
	}
	return m
}

func (intSlice IntSlice) Min() int {
	var m int
	for _, val := range intSlice {
		m = int(math.Max(float64(val),float64(m)))
	}
	return m
}

func (intSlice IntSlice) MaxBy(f func(num int) int) int {
	var slice IntSlice
	for _, val := range intSlice {
		slice = append(slice, f(val))
	}
	return slice.Max()
}

func (intSlice IntSlice) MinBy(f func(num int) int) int {
	var slice IntSlice
	for _, val := range intSlice {
		slice = append(slice, f(val))
	}
	return slice.Min()
}

func (intSlice IntSlice) Distinct() IntSlice {
	var set map[int]bool
	var slice IntSlice

	set = make(map[int]bool)

	for _, val := range intSlice {
		if ok := set[val]; !ok {
			set[val] = true
			slice = append(slice, val)
		}
	}

	return slice
}

func (intSlice IntSlice) Sort() IntSlice {
	var slice IntSlice

	slice = intSlice.AsValue()
	sort.Sort(sort.IntSlice([]int(slice)))

	return slice
}

func (intSlice IntSlice) All(f func(num int) bool) bool {
	return reflect.DeepEqual(intSlice, intSlice.Filter(f))
}

func (intSlice IntSlice) Any(f func(num int) (ok bool)) bool {
	return intSlice.Filter(f).IsNotEmpty()
}

func (intSlice IntSlice) IsEmpty() bool {
	return 0 == len(intSlice)
}

func (intSlice IntSlice) IsNotEmpty() bool {
	return 0 < len(intSlice)
}

func (intSlice IntSlice) None(f func(num int) bool) bool {
	return intSlice.Filter(f).IsEmpty()
}

func (intSlice IntSlice) Sum() int {
	var result int

	for _, val := range intSlice {
		result += val
	}
	return result
}

func (intSlice IntSlice) Average() int {
	return intSlice.Sum() / len(intSlice)
}

func (intSlice IntSlice) Plus(s IntSlice) IntSlice {
	var slice IntSlice

	slice = intSlice.AsValue()
	slice = append(slice, s...)

	return slice
}

func (intSlice IntSlice) Count() int {
	return len(intSlice)
}

func scanNum() int {
	input.Scan()
	num, err := strconv.Atoi(input.Text())
	if err != nil {
		panic(err)
	}

	return num
}

func main() {
	var N, x int
	var a IntSlice

	input.Split(bufio.ScanWords)

	N = scanNum()
	x = scanNum()

	for i := 0; i < N; i++ {
		a = append(a, scanNum())
	}

	count := a.Sort().Filter(func(n int) bool{x -= n;return 0 <= x}).Count()
	if 0 < x {
		count--
	}
	fmt.Println(count)
}


Measured memory_bytes: 640