use std::vec::Vec; use std::cmp::min; use std::cmp::max; fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::().split_whitespace().map(|e| e.parse().ok().unwrap()).collect() } fn main() { let (n, k) = { let v: Vec = read_vec(); (v[0], v[1] - 1) }; let x: Vec = read_vec(); let a: Vec = read_vec(); let mut wave_range_right = x[k] + a[k]; let mut wave_range_left = x[k] - a[k]; // 右側のカエル for i in k+1..n { if wave_range_right >= x[i] { wave_range_right = max(wave_range_right, x[i] + a[i]); wave_range_left = min(wave_range_left, x[i] - a[i]); } } // 左側のカエル for i in (0..k).rev() { if wave_range_left <= x[i] { wave_range_right = max(wave_range_right, x[i] + a[i]); wave_range_left = min(wave_range_left, x[i] - a[i]); } } let mut ans = 0; for i in 0..n { if wave_range_left <= x[i] && x[i] <= wave_range_right { ans += 1; } } println!("{}", ans); //println!("{}", wave_range_left); //println!("{}", wave_range_right); }