#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 = p[k].first; int mn_id = k; for (int i = k; i < n; i++) { if (mn > p[i].first) { mn = p[i].first; mn_id = i; } } long long mx = p[k].second; int mx_id = k; for (int i = k; i >= 0; i--) { if (mx < p[i].second) { mx = p[i].second; mx_id = i; } } vector cnt(n , 0); for (int i = k; i < n; i++) { if (a[i] <= mx) { cnt[i] = 1; if (p[i].second >= mx) { mx = p[i].second; mx_id = i; } } } for (int i = k; i >= 0; i--) { if (a[i] >= mn) { cnt[i] = 1; if (p[i].first <= mn) { mn = p[i].first; mn_id = i; } } } int ans = 0; for (int i = 0; i < n; i++) { ans += cnt[i] > 0; } cout << ans << endl; return 0; }