use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let k: usize = itr.next().unwrap().parse::().unwrap() - 1; let x: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut left = k; let mut lv = x[k] - a[k]; let mut right = k; let mut rv = x[k] + a[k]; loop { let mut updated = false; let mut tmpl = lv; let mut tmpr = rv; while left > 0 && lv <= x[left - 1] { updated = true; left -= 1; tmpl = std::cmp::min(tmpl, x[left] - a[left]); tmpr = std::cmp::max(tmpr, x[left] + a[left]); } while right < n - 1 && rv >= x[right + 1] { updated = true; right += 1; tmpl = std::cmp::min(tmpl, x[right] - a[right]); tmpr = std::cmp::max(tmpr, x[right] + a[right]); } lv = tmpl; rv = tmpr; if !updated { break; } } println!("{}", right - left + 1); }