use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize, x: isize,
      mut aa: [isize; n]
    };

    aa.sort();

    let mut total = x;
    let mut c = 0;
    let sum: isize = aa.iter().sum();

    for i in 0..n {
        if i == n - 1 && sum != x {
            c -= 1;
        }

        if &total >= &aa[i] {
            total -= &aa[i];
            c += 1;
        } else {
            break;
        }
    }

    println!("{}", c);
}
