#include #include #include #include #include #include #include #include #include using namespace std; int main() { int n , k; cin >> n >> k; k--; vector X(n); for (int i = 0; i < n; i++) { cin >> X[i]; } vector A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int x = k , y = k; int ans = 0; long long mx = -1e18; long long mn = 1e18; queue qx , qy; qx.push(k); qy.push(k); while (qx.size() > 0 || qy.size() > 0) { x = qx.front(); qx.pop(); mx = max(mx , X[x] + A[x]); if (x + 1 < n && X[x + 1] <= mx) { qx.push(x + 1); } y = qy.front(); qy.pop(); mn = min(mn , X[y] - A[y]); if (0 <= y - 1 && mn <= X[y - 1]) { qy.push(y - 1); } } cout << x - y + 1 << endl; return 0; }