use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n = it.next().unwrap().parse::().unwrap() + 2; let k = it.next().unwrap().parse::().unwrap(); let mut x = vec![-1_000_000_000_000_000_000i64; n]; for i in 1..(n - 1) { x[i] = it.next().unwrap().parse().unwrap(); } x[n - 1] = -x[n - 1]; let mut a = vec![0i64; n]; for i in 1..(n - 1) { a[i] = it.next().unwrap().parse().unwrap(); } let mut i = k + 1; let mut j = k - 1; let mut l = x[k] - a[k]; let mut r = x[k] + a[k]; loop { if x[i] < r { r = std::cmp::max(x[i] + a[i], r); l = std::cmp::min(x[i] - a[i], l); i += 1; } else if x[j] >= l { r = std::cmp::max(x[j] + a[j], r); l = std::cmp::min(x[j] - a[j], l); j -= 1; } else { break; } } let ans = i - j - 1; println!("{}", ans); } fn main() { run(); }