#include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)n - 1; i > -1; i--) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair pll; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; K--; vector X(N), A(N); vector kukan(N); rep(i, N) { cin >> X[i]; } rep(i, N) { cin >> A[i]; } rep(i, N) { kukan[i].first = X[i] - A[i]; kukan[i].second = X[i] + A[i]; } int right = K, left = K; while (right < N - 1) { ll tar = kukan[right].second; ll cur = upper_bound(all(X), tar) - X.begin() - 1; if (cur == right) break; right = cur; } while (left > 0) { ll tar = kukan[left].first; ll cur = lower_bound(all(X), tar) - X.begin(); if (cur == left) break; left = cur; } cout << right - left + 1 << endl; }