use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut x: i64 = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    a.sort();
    let mut ans = 0;
    for i in 0..n {
        if x >= a[i] {
            x -= a[i];
            ans = i + 1;
        }
    }
    if x > 0 && ans > 0 {
        ans -= 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
