#include using namespace std; using LL = long long; LL x[111111], a[111111]; int main(){ // 1. 入力情報取得. int N, K; scanf("%d %d", &N, &K); K--; for(int i = 0; i < N; i++) scanf("%lld", &x[i]); for(int i = 0; i < N; i++) scanf("%lld", &a[i]); // 2. 区間の最小を計算. LL minL = x[K] - a[K]; int indexL = max(0, K - 1); while(1){ LL l = 1e17; int index = 0; for(int i = indexL; i >= 0; i--) if(l >= minL && l >= x[i]) l = min(l, x[i] - a[i]), index = i; if(l < minL) minL = l, indexL = index; else break; } // 3. 区間の最大を計算. LL maxR = x[K] + a[K]; int indexR = min(K + 1, N - 1); while(1){ LL r = -1e17; int index = 0; for(int i = indexR; i < N; i++) if(r >= maxR && r >= x[i]) r = max(r, x[i] - a[i]), index = i; if(r > maxR) maxR = r, indexR = index; else break; } // 4. 出力 ~ 後処理. printf("%d\n", indexR - indexL); return 0; }