use proconio::input;

fn main() {
    input!{
        n: i64,
        x: i64,
        a: [i64; n],
    }

    let mut x = x;
    let mut a = a;
    let mut b = vec![0; n as usize];

    a.sort();

    for i in 0..n {
        if x >= a[i as usize] {
            b[i as usize] = a[i as usize];
            x -= a[i as usize];
        }
    }

    let mut ans = 0;

    for i in 0..n {
        if a[i as usize] == b[i as usize] {
            ans += 1;
        }
    }

    if ans > 0 &&  x > 0 {
        ans -= 1;
    }

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