use std::cmp::max; use std::collections::HashMap; fn main() { let mut nw = String::new(); std::io::stdin().read_line(&mut nw).ok(); let nw: Vec = nw.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nw[0]; let w = nw[1]; let mut a: Vec = vec![]; for _ in 0..n { let mut tempa = String::new(); std::io::stdin().read_line(&mut tempa).ok(); let tempa: usize = tempa.trim().parse().unwrap(); a.push(tempa); } let mut result = 0usize; let mut val: usize = 0usize; let mut used: HashMap = HashMap::new(); let mut sidx = 0usize; for i in 0..n { val += a[i]; if let Some(x) = used.get_mut(&a[i]) { while sidx <= *x { val -= a[sidx]; sidx += 1; } *x = i; } else { used.insert(a[i], i); } while w < val { val -= a[sidx]; sidx += 1; } result = max(result, i + 1 - sidx); } println!("{}", result); }