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 = String::new(); std::io::stdin().read_line(&mut a).ok(); let mut a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut dp = vec![vec![vec![false; k+1]; n+2]; 2]; dp[0][0][0] = true; dp[1][0][0] = true; for pat in 0..2 { for i in 0..n { for j in 0..=k { if !dp[pat][i][j] { continue; } dp[pat][i+1][j] = true; if j + a[i] <= k { dp[pat][i+1][j+a[i]] = true; } } } a.reverse(); } dp[1].reverse(); if !dp[0][n][k] { println!("-1"); return; } let mut result = 0usize; for i in 0..n { if !(0..=k).any(|j| dp[0][i][j] && dp[1][i+2][k-j]) { result += 1; } } println!("{}", result); }