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

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

fn main() {

    #[allow(non_snake_case)]
    let N: u32 = read();
    let mut x: i32 = read();
    println!("N {}, x {}", N, x);

    let mut result: u8 = 0;


    for i in 0..N {

        let a: i32 = read();
        println!("i {}, a {}", i, a);

        if x < a {

            continue;
        }
        if (x - a) >= 0 {

            println!("x {}", x);
            if i == N - 1 && x != a {

                break;
            }
            x -= a;
            result += 1;
        }
    }

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