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