use std::io;

#[allow(unused_must_use)]
fn main() {
    let (n, x) = {
        let s = {
            let mut s = String::new();
            io::stdin().read_line(&mut s).unwrap();
            s.trim_right().to_owned()
        };
        let mut ws = s.split_whitespace();
        let n: i32 = ws.next().unwrap().parse().unwrap();
        let x: i32 = ws.next().unwrap().parse().unwrap();
        (n, x)
    };
    let mut a: Vec<i32> = {
        let s = {
            let mut s = String::new();
            io::stdin().read_line(&mut s).unwrap();
            s.trim_right().to_owned()
        };
        let mut ws = s.split_whitespace();
        let mut a = vec![];
        for i in ws {
            a.push(i.parse().unwrap());
        }
        a
    };
    if x == a.iter().sum() {
        print!("{}", n);
        return
    }
    a.sort();
    let mut xx = x;
    let mut cnt = 0;
    for ai in a {
        xx = xx - ai;
        if xx < 0 {
            print!("{}", cnt);
            return
        }
        cnt = cnt + 1;
    }
    print!("{}", cnt - 1);
}
