fn main() { let mut nk = String::new(); std::io::stdin().read_line(&mut nk).ok(); let nk: Vec = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nk[0]; let k = nk[1]; let mut a: Vec = vec![]; for _ in 0..n { let mut aa = String::new(); std::io::stdin().read_line(&mut aa).ok(); let aa: usize = aa.trim().parse().unwrap(); a.push(aa); } let mut dp: Vec> = vec![vec![false; k+1]; n+1]; dp[0][0] = true; for i in 0..n { for j in 0..=k { dp[i+1][j] |= dp[i][j]; if a[i] <= j { dp[i+1][j] |= dp[i][j-a[i]]; } } } println!("{}", dp[n].iter().enumerate().filter(|pair| *pair.1).map(|pair| pair.0).max().unwrap()); }