#include #include #include #include #include #include #include #include #include using namespace std; int main() { int n , k; cin >> n >> 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]; } vector > p(n); for (int i = 0; i < n; i++) { p[i]= make_pair(x[i] - a[i] , x[i] + a[i]); } k--; /* if (a[k] == 0) { cout << 1 << endl; return 0; } */ long long mn = p[k].first; for (int i = k; i < n - 1; i++) { if (x[i + 1] <= p[i].second && mn >= p[i + 1].first) { mn = p[i].first; } else { break; } } long long mx = p[k].second; for (int i = k; i >= 1; i--) { if (x[i - 1] >= p[i].first && mx <= p[i - 1].second) { mx = p[i - 1].second; } else { break; } } vector cnt(n , 0); cnt[k] = 1; for (int i = k; i < n; i++) { if (x[i] <= mx) { cnt[i] = cnt[k]; if (p[i].second >= mx) { mx = p[i].second; } } } for (int i = k; i >= 0; i--) { if (x[i] >= mn) { cnt[i] = cnt[k]; if (p[i].first <= mn) { mn = p[i].first; } } } int ans = 0; for (int i = 0; i < n; i++) { ans += cnt[i] > 0; } cout << ans << endl; return 0; }