#pragma GCC optimize("O3") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; using T = tuple; template inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;} template inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;} constexpr int MOD = 1e9 + 7; constexpr int inf = 1e9; constexpr long long INF = 1e18; #define all(a) (a).begin(), (a).end() int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, k; cin>>n>>k; vector x(n+2), a(n+1); x[0] = -INF, x[n+1] = INF; for(int i=1; i<=n; i++) cin>>x[i]; for(int i=1; i<=n; i++) cin>>a[i]; int ub = k, mub = -1; for(int i=k; i<=ub; i++){ ll dist = x[i] + a[i]; int ub = upper_bound(all(x), dist) - x.begin() - 1; chmax(mub, ub); } int lb = k, mlb = n + 1; for(int i=k; i>=lb; i--){ ll dist = x[i] - a[i]; int lb = lower_bound(all(x), dist) - x.begin(); chmin(mlb, lb); } cout << mub - mlb + 1 << endl; return 0; }