#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define prs printf(" ")
#define prn printf("\n")
#define scc(a) scanf("%c", &a)
#define scst(a) scanf("%s", a)
#define sci(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)

#define prc(a) printf("%c", a)
#define prst(a) printf("%s", a)
#define pri(a) printf("%d", a)
#define prll(a) printf("%lld", a)

#define FOR(i, a, b) for(int i = a; i<=b; i++)
#define ROF(i, a, b) for(int i = a; i>=b; i--)
#define pria(i, a, b, A) FOR(i, a, b) {pri(A[i]);prs;}
#define prlla(i, a, b, A) FOR(i, a, b) {prll(A[i]);prs;}
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != c.end(); i++)

#define mp make_pair
#define pb push_back

inline ll max(ll a, ll b) {return (a<b)?b:a;}
inline ll min(ll a,ll b) {return (a<b)?a:b;}

char s[100005];
int l;
vector<ll> v;
void change(int x, int y){
	if(x>=l || x>y || y >= l)
		return;
	else{
		FOR(i, x, y){
			if(s[i]=='a')
				s[i]='z';
			else
				s[i]-=1;
		}
	}
	return;
}

int main(){
	scst(s);
	l = strlen(s);
	bool fl=1;
	int x=l,y=l, i;
	ll k, m;
	FOR(i, 0, l-1){
		if(s[i]=='a'){
			x=i;
			v.pb(i);
		}
	}
	if(v.size()==0){ // no a
		change(0, l-1);
	}
	else if(v.size()==1){ // one a
		if(x==0)
			change(1, l-1);
		else
			change(0, x-1);
	}
	else if(v[0] != 0){
		change(0, v[0]-1);
	}
	else{ // many adjacent a
		ll f = v.size();
		if(f == l){
			s[l-1]='z';
		}
		else{
			FOR(i, 1, l-1){
				if(s[i]=='a' && s[i-1] == 'a'){
					continue;
				}
				else{
					k=i;
					break;
				}
			}
			m=l-1;
			FOR(i, k, l-1){
				if(s[i]=='a'){
					m=i;
					break;
				}
			}
			change(k, m-1);
		}
	}
	prst(s);prn;
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define prs printf(" ")
#define prn printf("\n")
#define scc(a) scanf("%c", &a)
#define scst(a) scanf("%s", a)
#define sci(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)

#define prc(a) printf("%c", a)
#define prst(a) printf("%s", a)
#define pri(a) printf("%d", a)
#define prll(a) printf("%lld", a)

#define FOR(i, a, b) for(int i = a; i<=b; i++)
#define ROF(i, a, b) for(int i = a; i>=b; i--)
#define pria(i, a, b, A) FOR(i, a, b) {pri(A[i]);prs;}
#define prlla(i, a, b, A) FOR(i, a, b) {prll(A[i]);prs;}
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != c.end(); i++)

#define mp make_pair
#define pb push_back

inline ll max(ll a, ll b) {return (a<b)?b:a;}
inline ll min(ll a,ll b) {return (a<b)?a:b;}

char s[100005];
int l;
vector<ll> v;
void change(int x, int y){
	if(x>=l || x>y || y >= l)
		return;
	else{
		FOR(i, x, y){
			if(s[i]=='a')
				s[i]='z';
			else
				s[i]-=1;
		}
	}
	return;
}

int main(){
	scst(s);
	l = strlen(s);
	bool fl=1;
	int x=l,y=l, i;
	ll k, m;
	FOR(i, 0, l-1){
		if(s[i]=='a'){
			x=i;
			v.pb(i);
		}
	}
	if(s[0]=='a' && l==1){
		s[0]='z';
		prst(s);prn;return 0;
	}
	if(v.size()==0){ // no a
		change(0, l-1);
	}
	else if(v.size()==1){ // one a
		if(x==0)
			change(1, l-1);
		else
			change(0, x-1);
	}
	else if(v[0] != 0){
		change(0, v[0]-1);
	}
	else{ // many adjacent a
		ll f = v.size();
		if(f == l){
			s[l-1]='z';
		}
		else{
			FOR(i, 1, l-1){
				if(s[i]=='a' && s[i-1] == 'a'){
					continue;
				}
				else{
					k=i;
					break;
				}
			}
			m=l-1;
			FOR(i, k, l-1){
				if(s[i]=='a'){
					m=i;
					break;
				}
			}
			change(k, m-1);
		}
	}
	prst(s);prn;
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define prs printf(" ")
#define prn printf("\n")
#define scc(a) scanf("%c", &a)
#define scst(a) scanf("%s", a)
#define sci(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)

#define prc(a) printf("%c", a)
#define prst(a) printf("%s", a)
#define pri(a) printf("%d", a)
#define prll(a) printf("%lld", a)

#define FOR(i, a, b) for(int i = a; i<=b; i++)
#define ROF(i, a, b) for(int i = a; i>=b; i--)
#define pria(i, a, b, A) FOR(i, a, b) {pri(A[i]);prs;}
#define prlla(i, a, b, A) FOR(i, a, b) {prll(A[i]);prs;}
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != c.end(); i++)

#define mp make_pair
#define pb push_back

inline ll max(ll a, ll b) {return (a<b)?b:a;}
inline ll min(ll a,ll b) {return (a<b)?a:b;}

char s[100005];
int l;
void change(int x, int y){
	if(x>l)
		return;
	else{
		FOR(i, x, y){
			if(s[i]=='a')
				s[i]='z';
			else
				s[i]-=1;
		}
	}
	return;
}

int main(){
	scst(s);
	l = strlen(s);
	bool fl=1;
	FOR(i, 0, l-1)
		if(s[i]!='a'){
			fl=0;
			break;
		}
		else
			fl=1;
	if(fl){

		s[l-1]='z';
		prst(s);prn;
		return 0;
	}
	vector<int> v;
	int x=l; int y=l;
	FOR(i, 0, l-1){
		if(s[i]=='a'){
			x=i;
			v.pb(i);
		}
	}

	if(v.size()==0){ // no a
		//cout<<"here1";
		change(0, l-1);
	}
	else if(v.size()==1){ // one a
		//cout<<"here2";
		if(x==0)
			change(1, l-1);
		else
			change(0, x-1);
	}
	else if(v[0] != 0){
		change(0, v[0]-1);
	}
	else{ // many adjacent a
		//cout<<"here\n";
		//cout<<v.size()<<endl;
		int i;
		int k;
		FOR(i, 1, v.size()-1){
			//cout<<v[i]-v[i-1]<<endl;
			if(v[i]-v[i-1]>1){
				k=i;
				break;
			}
		}
		i=k;
		//cout<<i<<endl;
		//cout<<v[i-1]+1<<" "<<v[i]-1<<endl;
		change(v[i-1]+1, v[i]-1);
	}
	prst(s);prn;
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define prs printf(" ")
#define prn printf("\n")
#define scc(a) scanf("%c", &a)
#define scst(a) scanf("%s", a)
#define sci(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)

#define prc(a) printf("%c", a)
#define prst(a) printf("%s", a)
#define pri(a) printf("%d", a)
#define prll(a) printf("%lld", a)

#define FOR(i, a, b) for(int i = a; i<=b; i++)
#define ROF(i, a, b) for(int i = a; i>=b; i--)
#define pria(i, a, b, A) FOR(i, a, b) {pri(A[i]);prs;}
#define prlla(i, a, b, A) FOR(i, a, b) {prll(A[i]);prs;}
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != c.end(); i++)

#define mp make_pair
#define pb push_back

inline ll max(ll a, ll b) {return (a<b)?b:a;}
inline ll min(ll a,ll b) {return (a<b)?a:b;}

char s[100005];
int l;
void change(int x, int y){
	if(x>=l)
		return;
	else{
		FOR(i, x, y){
			if(s[i]=='a')
				s[i]='z';
			else
				s[i]-=1;
		}
	}
	return;
}

int main(){
	scst(s);
	l = strlen(s);
	bool fl=1;
	FOR(i, 0, l-1)
		if(s[i]!='a'){
			fl=0;
			break;
		}
		else
			fl=1;
	if(fl){

		s[l-1]='z';
		prst(s);prn;
		return 0;
	}
	vector<int> v;
	int x=l; int y=l;
	FOR(i, 0, l-1){
		if(s[i]=='a'){
			x=i;
			v.pb(i);
		}
	}

	if(v.size()==0){ // no a
		//cout<<"here1";
		change(0, l-1);
	}
	else if(v.size()==1){ // one a
		//cout<<"here2";
		if(x==0)
			change(1, l-1);
		else
			change(0, x-1);
	}
	else if(v[0] != 0){
		change(0, v[0]-1);
	}
	else{ // many adjacent a
		//cout<<"here\n";
		//cout<<v.size()<<endl;
		int i;
		int k;
		FOR(i, 1, v.size()-1){
			//cout<<v[i]-v[i-1]<<endl;
			if(v[i]-v[i-1]>1){
				k=i;
				break;
			}
		}
		i=k;
		//cout<<i<<endl;
		//cout<<v[i-1]+1<<" "<<v[i]-1<<endl;
		change(v[i-1]+1, v[i]-1);
	}
	prst(s);prn;
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define prs printf(" ")
#define prn printf("\n")
#define scc(a) scanf("%c", &a)
#define scst(a) scanf("%s", a)
#define sci(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)

#define prc(a) printf("%c", a)
#define prst(a) printf("%s", a)
#define pri(a) printf("%d", a)
#define prll(a) printf("%lld", a)

#define FOR(i, a, b) for(int i = a; i<=b; i++)
#define ROF(i, a, b) for(int i = a; i>=b; i--)
#define pria(i, a, b, A) FOR(i, a, b) {pri(A[i]);prs;}
#define prlla(i, a, b, A) FOR(i, a, b) {prll(A[i]);prs;}
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != c.end(); i++)

#define mp make_pair
#define pb push_back

inline ll max(ll a, ll b) {return (a<b)?b:a;}
inline ll min(ll a,ll b) {return (a<b)?a:b;}

char s[100005];
int l;
void change(int x, int y){
	if(x>l)
		return;
	else{
		FOR(i, x, y){
			if(s[i]=='a')
				s[i]='z';
			else
				s[i]-=1;
		}
	}
	return;
}

int main(){
	int i;
	scst(s);
	l = strlen(s);
	int x=l; int y=l;
	FOR(i, 0, l-1){
		if(s[i]=='a'){
			x = i;
			break;
		}
	}
	FOR(i, x+1, l-1){
		if(s[i]=='a'){
			y = i;
			break;
		}
	}
	//cout<<x<<" "<<y<<endl;
	if(x == l){ // no a
		//cout<<"here1";
		change(0, l-1);
	}
	else if(x!=l && y == l){ // one a
		//cout<<"here2";
		if(x==0)
			change(1, l-1);
		else
			change(0, x-1);
	}
	else if(x!=l && y!=l && y-x==1){ // two adjacent a
		//cout<<"here3";
		if(x==0)
			change(2, l-1);
		else
			change(0, x-1);
	}
	else{ // else
		//cout<<"here4";
		if(x==0)
			change(1, y-1);
		else
			change(0, x-1);
	}
	prst(s);prn;
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define prs printf(" ")
#define prn printf("\n")
#define scc(a) scanf("%c", &a)
#define scst(a) scanf("%s", a)
#define sci(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)

#define prc(a) printf("%c", a)
#define prst(a) printf("%s", a)
#define pri(a) printf("%d", a)
#define prll(a) printf("%lld", a)

#define FOR(i, a, b) for(int i = a; i<=b; i++)
#define ROF(i, a, b) for(int i = a; i>=b; i--)
#define pria(i, a, b, A) FOR(i, a, b) {pri(A[i]);prs;}
#define prlla(i, a, b, A) FOR(i, a, b) {prll(A[i]);prs;}
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != c.end(); i++)

#define mp make_pair
#define pb push_back

inline ll max(ll a, ll b) {return (a<b)?b:a;}
inline ll min(ll a,ll b) {return (a<b)?a:b;}

char s[100005];
int l;
void change(int x, int y){
	if(x>l)
		return;
	else{
		FOR(i, x, y){
			if(s[i]=='a')
				s[i]='z';
			else
				s[i]-=1;
		}
	}
	return;
}

int main(){
	int i;
	scst(s);
	l = strlen(s);
	if(s[0]=='a'&&l==1){
		s[0]='z';
		prst(s);prn;
		return 0;
	}
	int x=l; int y=l;
	FOR(i, 0, l-1){
		if(s[i]=='a'){
			x = i;
			break;
		}
	}
	FOR(i, x+1, l-1){
		if(s[i]=='a'){
			y = i;
			break;
		}
	}
	//cout<<x<<" "<<y<<endl;
	if(x == l){ // no a
		//cout<<"here1";
		change(0, l-1);
	}
	else if(x!=l && y == l){ // one a
		//cout<<"here2";
		if(x==0)
			change(1, l-1);
		else
			change(0, x-1);
	}
	else if(x!=l && y!=l && y-x==1){ // two adjacent a
		//cout<<"here3";
		if(x==0)
			change(2, l-1);
		else
			change(0, x-1);
	}
	else{ // else
		//cout<<"here4";
		if(x==0)
			change(1, y-1);
		else
			change(0, x-1);
	}
	prst(s);prn;
	return 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p, c;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(s[p] == 'a')
		p++;
	if (p == n)
		s[n - 1] = 'z';
	else {
		w(s[p] != 'a' && p<n)
			s[p]--, p++;
	}
	cout << s << endl;
	cin >> n;
	re 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p, c;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(true) {
		if (s[p] == 'a') {
			if (!c)
				c++;
			else
				break;
		}
		else
			s[p]--, c++;
		p++;
		if (p == n)
			break;
	}
	cout << s << endl;
	cin >> n;
	re 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p, c;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(true) {
		if (s[p] == 'a') {
			if (!c)
				c++;
			else
				break;
		}
		else
			s[p]--, c++;
		p++;
		if (p == n)
			break;
	}
	if (n == 1 && s[0] == 'a')
		s[0] = 'z';
	cout << s << endl;
	cin >> n;
	re 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p, c;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(true) {
		if (s[p] == 'a') {
			if (!c)
				c++;
			else
				break;
		}
		else
			s[p]--;
		p++;
	}
	cout << s << endl;
	cin >> n;
	re 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p, c;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(s[p] == 'a')
		p++;
	if (p == n)
		s[n - 1] = 'z';
	else {
		w(s[p] != 'a')
			s[p]--, p++;
	}
	cout << s << endl;
	cin >> n;
	re 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(s[p] != 'a' && p < n)
		s[p]--, p++;
	cout << s << endl;
	cin >> n;
	re 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, p, c;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	n = s.size();
	w(true) {
		if (s[p] == 'a') {
			if (!c)
				c++;
			else
				break;
		}
		else
			s[p]--;
		p++;
		if (p == n)
			break;
	}
	cout << s << endl;
	cin >> n;
	re 0;
}


/*
 * S2.cpp
 *
 *  Created on: Aug 24, 2016
 *      Author: mohamedelzarei
 */

#include <iostream>
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef long long ll;
typedef unsigned long long ull;

#define all(x) x.begin(),x.end()
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf (1<<29)
#define oo (ll)(1e16)
#define vi vector<int>
#define endl "\n"
#define lp(i,j) for(int i = 0; i < j;i++)
#define sz(a) a.size()

#define make_cin_fast std::ios_base::sync_with_stdio(false);
#define clean(vis)  memset(vis,0,sizeof vis)
#define D(x) cout << "The value of X is " << x << endl;
#define RUN

#ifdef RUN
int main(int argc, const char ** argv)
{
    make_cin_fast
	string ln;
    cin >> ln;
    int p1 = 0, p2 = 0;
    int N = sz(ln);
    string ans = ln;
    while(p1 < N){
    	string curr_ans = ln;
		if(p1 > p2 ) p2++;
    	while(p2 < N){
//    		cout << p2 << " " << ln[p2] << endl;
    		if(ln[p2] == 'a') break;
    		curr_ans[p2] = ln[p2] - 1;
    		p2++;
    	}
    	if(curr_ans < ans)
    		ans = curr_ans;

    	if(p2 >= N) break;
    	p1++;

    }
    if(ans == ln){
    	ans[0] = 'z';
    }
    cout << ans << endl;
    return 0;
}
#endif


/*
 * S2.cpp
 *
 *  Created on: Aug 24, 2016
 *      Author: mohamedelzarei
 */
/*
 تجري الرياح كما تجري سفينتنا .. نحن الرياح و نحن البحر و السفن ُ
 إن الذي يرتجي شيئاً بهمّتهِ .. يلقاهُ لو حاربَتْهُ الانسُ والجنُ ..
 ُّفاقصد الى قمم الاشياءِ تدركها .. تجري الرياح كما رادت لها السفنُ —
 */

#include <iostream>
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef long long ll;
typedef unsigned long long ull;

#define all(x) x.begin(),x.end()
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf (1<<29)
#define oo (ll)(1e16)
#define vi vector<int>
#define endl "\n"
#define lp(i,j) for(int i = 0; i < j;i++)
#define sz(a) a.size()

#define make_cin_fast std::ios_base::sync_with_stdio(false);
#define clean(vis)  memset(vis,0,sizeof vis)
#define D(x) cout << "The value of X is " << x << endl;
//#define RUN

#ifdef RUN
int main(int argc, const char ** argv)
{
	make_cin_fast
	string ln;
	cin >> ln;
	bool found = 1;
	for(auto &x : ln) {
		if(x != 'a') {
			x -= 1;
			found = 0;
		} else {
			if(!found) break;
		}
	}

	if(found) {
		ln[sz(ln)-1] = 'z';
	}

	cout << ln << endl;
	return 0;
}
#endif


/*
 * S2.cpp
 *
 *  Created on: Aug 24, 2016
 *      Author: mohamedelzarei
 */

#include <iostream>
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef long long ll;
typedef unsigned long long ull;

#define all(x) x.begin(),x.end()
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf (1<<29)
#define oo (ll)(1e16)
#define vi vector<int>
#define endl "\n"
#define lp(i,j) for(int i = 0; i < j;i++)
#define sz(a) a.size()

#define make_cin_fast std::ios_base::sync_with_stdio(false);
#define clean(vis)  memset(vis,0,sizeof vis)
#define D(x) cout << "The value of X is " << x << endl;
#define RUN

#ifdef RUN
int main(int argc, const char ** argv)
{
    make_cin_fast
	string ln;
    cin >> ln;
    int p1 = 0, p2 = 0;
    int N = sz(ln);
    string ans = ln;
    while(p1 < N){
    	string curr_ans = ln;
		if(p1 > p2 ) p2++;
    	while(p2 < N){
//    		cout << p2 << " " << ln[p2] << endl;
    		if(ln[p2] == 'a') break;
    		curr_ans[p2] = ln[p2] - 1;
    		p2++;
    	}
    	if(curr_ans < ans)
    		ans = curr_ans;

    	if(p2 >= N) break;
    	p1++;

    }
    if(ans == ln){
    	ans[sz(ln)-1] = 'z';
    }
    cout << ans << endl;
    return 0;
}
#endif


/*
 * S2.cpp
 *
 *  Created on: Aug 24, 2016
 *      Author: mohamedelzarei
 */

#include <iostream>
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef long long ll;
typedef unsigned long long ull;

#define all(x) x.begin(),x.end()
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf (1<<29)
#define oo (ll)(1e16)
#define vi vector<int>
#define endl "\n"
#define lp(i,j) for(int i = 0; i < j;i++)
#define sz(a) a.size()

#define make_cin_fast std::ios_base::sync_with_stdio(false);
#define clean(vis)  memset(vis,0,sizeof vis)
#define D(x) cout << "The value of X is " << x << endl;
#define RUN

#ifdef RUN
int main(int argc, const char ** argv)
{
    make_cin_fast
	string ln;
    cin >> ln;
    bool found = 0;
    for(auto &x : ln){
    	if(x != 'a'){
    		x -= 1;
    		found = 1;
    	}
    	if(x == 'a' && found) break;
    }

    if(!found){
    	ln[sz(ln)-1] = 'z';
    }

    cout << ln << endl;
    return 0;
}
#endif


/*
 * S2.cpp
 *
 *  Created on: Aug 24, 2016
 *      Author: mohamedelzarei
 */

#include <iostream>
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef long long ll;
typedef unsigned long long ull;

#define all(x) x.begin(),x.end()
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf (1<<29)
#define oo (ll)(1e16)
#define vi vector<int>
#define endl "\n"
#define lp(i,j) for(int i = 0; i < j;i++)
#define sz(a) a.size()

#define make_cin_fast std::ios_base::sync_with_stdio(false);
#define clean(vis)  memset(vis,0,sizeof vis)
#define D(x) cout << "The value of X is " << x << endl;
#define RUN

#ifdef RUN
int main(int argc, const char ** argv)
{
    make_cin_fast
	string ln;
    cin >> ln;
    bool found = 1;
    for(auto &x : ln){
    	if(x != 'a'){
    		x -= 1;
    		found = 0;
    	}else{
    		if(!found) break;
    	}
    }

    if(found){
    	ln[sz(ln)-1] = 'z';
    }

    cout << ln << endl;
    return 0;
}
#endif


/*
 * S2.cpp
 *
 *  Created on: Aug 24, 2016
 *      Author: mohamedelzarei
 */

#include <iostream>
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef long long ll;
typedef unsigned long long ull;

#define all(x) x.begin(),x.end()
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf (1<<29)
#define oo (ll)(1e16)
#define vi vector<int>
#define endl "\n"
#define lp(i,j) for(int i = 0; i < j;i++)
#define sz(a) a.size()

#define make_cin_fast std::ios_base::sync_with_stdio(false);
#define clean(vis)  memset(vis,0,sizeof vis)
#define D(x) cout << "The value of X is " << x << endl;
#define RUN

#ifdef RUN
int main(int argc, const char ** argv)
{
    make_cin_fast
	string ln;
    cin >> ln;
    int p1 = 0, p2 = 0;
    int N = sz(ln);
    string ans = ln;
    while(p1 < N){
    	string curr_ans = ln;
		if(p1 > p2 ) p2++;
    	while(p2 < N){
//    		cout << p2 << " " << ln[p2] << endl;
    		if(ln[p2] == 'a') break;
    		curr_ans[p2] = ln[p2] - 1;
    		p2++;
    	}
    	if(curr_ans < ans)
    		ans = curr_ans;

    	if(p2 >= N) break;
    	p1++;

    }
    	cout << ans << endl;
    return 0;
}
#endif


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	string s;
	cin>>s;
	ll n=s.size();
	string copy=s;
	ll flag=0;
	ll i=0;
	while(copy[i]!='a'&&i<n)
	{
		copy[i]=copy[i]-1;
		cout<<copy[i];
		i++;flag=1;
	}
	if(flag==1)
	{

	for(ll j=i;j<n;j++)
	{
		cout<<copy[j];
	}
	}
	else if(flag==0)
	{
		if(n==1)
		{
			cout<<"z";
		}
		else
		{
			ll i=0;
			while(copy[i]=='a'&&i<n)
			{
				cout<<copy[i];
				i++;
				if(i==n-1)
				{
					break;
				}
			}
			if(i==n-1)
			{
				cout<<"z";
			}
			else
			{
				while(copy[i]!='a')
				{
					copy[i]=copy[i]-1;
					cout<<copy[i];
					i++;
				}
				for(ll j=i;i<n;i++)
				{
					cout<<copy[i];
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);;cin.tie(0);
	string copy;
	cin>>copy;
	ll n=copy.size();
	ll flag=0;
	ll i=0;
	while(copy[i]!='a'&&i<n)
	{
		copy[i]=copy[i]-1;
		cout<<copy[i];
		i++;flag=1;
	}
	if(flag==1)
	{

	for(ll j=i;j<n;j++)
	{
		cout<<copy[j];
	}
	}
	else if(flag==0)
	{
		if(n==1)
		{
			cout<<"z";
		}
		else
		{
			ll i=0;
			while(copy[i]=='a'&&i<n)
			{
				cout<<copy[i];
				i++;
				if(i==(n-1))
				{
					break;
				}
			}
			if(i==n-1)
			{
				cout<<"z";
			}
			else
			{
				while(copy[i]!='a'&&i<n)
				{
					copy[i]=copy[i]-1;
					cout<<copy[i];
					i++;
				}
				for(ll j=i;j<n;j++)
				{
					cout<<copy[j];
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);;cin.tie(0);
	string copy;
	cin>>copy;
	ll n=copy.size();
	ll flag=0;
	ll i=0;
	while(copy[i]!='a'&&i<n)
	{
		copy[i]=copy[i]-1;
		cout<<copy[i];
		i++;flag=1;
	}
	if(flag==1)
	{

	for(ll j=i;j<n;j++)
	{
		cout<<copy[j];
	}
	}
	else if(flag==0)
	{
		if(n==1)
		{
			cout<<"z";
		}
		else
		{
			ll i=0;
			while(copy[i]=='a'&&i<n)
			{
				cout<<copy[i];
				i++;
				if(i==(n-1))
				{
					break;
				}
			}
			if(i==(n-1)&&copy[i]=='a')
			{
				cout<<"z";
			}
			else
			{
				while(copy[i]!='a'&&i<n)
				{
					copy[i]=copy[i]-1;
					cout<<copy[i];
					i++;
				}
				for(ll j=i;j<n;j++)
				{
					cout<<copy[j];
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);;cin.tie(0);
	string copy;
	cin>>copy;
	ll n=copy.size();
	ll flag=0;
	ll i=0;
	while(copy[i]!='a'&&i<n)
	{
		copy[i]=copy[i]-1;
		cout<<copy[i];
		i++;flag=1;
	}
	if(flag==1)
	{

	for(ll j=i;j<n;j++)
	{
		cout<<copy[j];
	}
	}
	else if(flag==0)
	{
		if(n==1)
		{
			cout<<"z";
		}
		else
		{
			ll i=0;
			while(copy[i]=='a'&&i<n)
			{
				cout<<copy[i];
				i++;
				if(i==(n-1))
				{
					break;
				}
			}
			if(i==n-1)
			{
				cout<<"z";
			}
			else
			{
				while(copy[i]!='a')
				{
					copy[i]=copy[i]-1;
					cout<<copy[i];
					i++;
				}
				for(ll j=i;j<n;j++)
				{
					cout<<copy[j];
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	//ios_base::sync_with_stdio(0);;cin.tie(0);
	string copy;
	cin>>copy;
	ll n=copy.size();
	ll flag=0;
	ll i=0;
	while(copy[i]!='a'&&i<n)
	{
		copy[i]=copy[i]-1;
		cout<<copy[i];
		i++;flag=1;
	}
	if(flag==1)
	{

	for(ll j=i;j<n;j++)
	{
		cout<<copy[j];
	}
	}
	else if(flag==0)
	{
		if(n==1)
		{
			cout<<"z";
		}
		else
		{
			ll i=0;
			while(copy[i]=='a'&&i<n)
			{
				cout<<copy[i];
				i++;
				if(i==(n-1))
				{
					break;
				}
			}
			if(i==(n-1)&&copy[i]=='a')
			{
				cout<<"z";
			}
			else
			{
				while(copy[i]!='a'&&i<n)
				{
					copy[i]=copy[i]-1;
					cout<<copy[i];
					i++;
				}
				for(ll j=i;j<n;j++)
				{
					cout<<copy[j];
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);;cin.tie(0);
	string copy;
	cin>>copy;
	ll n=copy.size();
	ll flag=0;
	ll i=0;
	for(ll i=0;i<n;i++)
	{
		if(copy[i]!='a')
		{
			copy[i]=copy[i]-1;
			flag=1;
		}
		else if(copy[i]=='a'&&flag==1)
		{
			break;
		}
	}
	if(flag==0)
	{
		copy[n-1]='z';
	}
	cout<<copy;
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
#define ll long long int
#define ak ios_base::sync_with_stdio(0);;cin.tie(0);
#define forin for(i=0;i<n;i++)
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	string copy;
	cin>>copy;
	ll n=copy.size();
	ll flag=0;
	ll i=0;
	while(copy[i]!='a'&&i<n)
	{
		copy[i]=copy[i]-1;
		cout<<copy[i];
		i++;flag=1;
	}
	if(flag==1)
	{

	for(ll j=i;j<n;j++)
	{
		cout<<copy[j];
	}
	}
	else if(flag==0)
	{
		if(n==1)
		{
			cout<<"z";
		}
		else
		{
			ll i=0;
			while(copy[i]=='a'&&i<n)
			{
				cout<<copy[i];
				i++;
				if(i==(n-1))
				{
					break;
				}
			}
			if(i==(n-1)&&copy[i]=='a')
			{
				cout<<"z";
			}
			else
			{
				while(copy[i]!='a'&&i<n)
				{
					copy[i]=copy[i]-1;
					cout<<copy[i];
					i++;
				}
				for(ll j=i;j<n;j++)
				{
					cout<<copy[j];
				}
			}
		}
	}
	return 0;
}


#include <iostream>

using namespace std;
int n,a,i,v[200001],v2[200001],rasp,poz,sum;
int main(int argc, char *argv[]) {
	cin>>n>>a;
	for(i=1;i<=n;i++) {
		cin>>v[i];
	}
	for(i=1;i<=n;i++) {
		cin>>v2[i];
	}
	sum=v[a]+v2[1];
	poz=n;
	for(i=1;i<=n;i++) {
		if(v[i]+v2[poz]<sum && i>a && poz>1) {
			rasp++;
			poz--;
		}
	}
	cout<<a-rasp;
}


#include <iostream>

using namespace std;
int n,a,i,v[200001],v2[200001],rasp,poz,sum;
int main(int argc, char *argv[]) {
	cin>>n>>a;
	for(i=1;i<=n;i++) {
		cin>>v[i];
	}
	for(i=1;i<=n;i++) {
		cin>>v2[i];
	}
	sum=v[a]+v2[1];
	poz=n;
	for(i=1;i<=n;i++) {
		if(v[i]+v2[poz]<sum && i<a && poz>1) {
			rasp++;
			poz--;
		}
	}
	cout<<a-rasp;
}


#include <iostream>

using namespace std;
int n,a,i,v[200001],v2[200001],rasp,poz,sum;
int main(int argc, char *argv[]) {
	cin>>n>>a;
	for(i=1;i<=n;i++) {
		cin>>v[i];
	}
	for(i=1;i<=n;i++) {
		cin>>v2[i];
	}
	sum=v[a]+v2[1];
	poz=n;
	for(i=1;i<=n;i++) {
		cout<<v[i]+v2[poz]<<" "<<sum<<'\n';
		if(v[i]+v2[poz]<sum && i<a && poz>1) {
			rasp++;
			poz--;
		}
	}
	cout<<a-rasp;
}


#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define db double
#define MAX 0x7fffffff
#define init inline int
#define INF 0X3fffffff

using namespace std;

inline long long read()
{
    ll f=1,s=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
    return s*f;
}

ll n,d;
ll s[1000001],p[1000001],pos=2,ans;

int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++) cin>>s[i];for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=d-1;i>0;i--){
    	while(s[d]+p[1]>s[i]+p[pos]){if(pos>n) break;pos++;}
	}
	cout<<n-pos;

}


#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define db double
#define MAX 0x7fffffff
#define init inline int
#define INF 0X3fffffff

using namespace std;

inline long long read()
{
    ll f=1,s=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
    return s*f;
}

ll n,d;
ll s[1000001],p[1000001],pos=2,ans;

int main()
{
    cin>>n>>d;
    ans=d;
    for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=d-1;i;--i){
    	while(s[d]+p[1]<s[i]+p[pos]&&pos<=n){pos++;}
    	if(pos>n) break;
		ans-=1;pos+=1;
	}
	cout<<ans;

}


#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define db double
#define MAX 0x7fffffff
#define init inline int
#define INF 0X3fffffff

using namespace std;

inline long long read()
{
    ll f=1,s=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
    return s*f;
}

ll n,d;
ll s[1000001],p[1000001],pos=2,ans;

int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++) cin>>s[i];for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=d-1;i>0;i--){
    	while(s[d]+p[1]>s[i]+p[pos]){if(pos>=n) break;pos++;}
    	if(pos>n) break;
	}
	cout<<abs(n-pos);

}


#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define db double
#define MAX 0x7fffffff
#define init inline int
#define INF 0X3fffffff

using namespace std;

inline long long read()
{
    ll f=1,s=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
    return s*f;
}

ll n,d;
ll s[1000001],p[1000001],pos=2,ans;

int main()
{
    cin>>n>>d;
    ans=d;
    for(int i=1;i<=n;i++) cin>>s[i];for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=d-1;i>0;--i){
    	while(s[d]+p[1]>s[i]+p[pos]&&pos<=n){pos++;}
    	if(pos>n) break;
		ans-=1;pos+=1;
	}
	cout<<ans;

}


#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define db double
#define MAX 0x7fffffff
#define init inline int
#define INF 0X3fffffff

using namespace std;

inline long long read()
{
    ll f=1,s=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
    return s*f;
}

ll n,d;
ll s[1000001],p[1000001],pos=2,ans;

int main()
{
    cin>>n>>d;
    ans=n;
    for(int i=1;i<=n;i++) cin>>s[i];for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=d-1;i>0;i--){
    	while(s[d]+p[1]>s[i]+p[pos]){if(pos>=n) break;pos++;}
    	if(pos>=n) break;
		ans--;pos++;
	}
	cout<<ans;

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,D;
int S[200001],P[200001];
vector<int>v1,v2;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>D;
  int X=0;
  for (int i=1;i<=N;i++){
    cin>>S[i];
    if (i==D)
      X+=S[i];
    else
      v1.push_back(S[i]);
  }
  for (int i=1;i<=N;i++){
    cin>>P[i];
    if (i==1)
      X+=P[i];
    else
      v2.push_back(P[i]);
  }
  int L=0;
  int R=v2.size()-1;
  int place=1;
  for (int i=0;i<v1.size();i++){
    if (v1[i]+v2[R]>=X){
      L++;
      place++;
    }
    else
      R--;
  }
  cout<<place<<endl;
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,D;
int S[200001],P[200001];
map<int,int>cnt;
vector<int>v;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>D;
  for (int i=1;i<=N;i++)
    cin>>S[i];
  for (int i=1;i<=N;i++)
    cin>>P[i];
  for (int i=1;i<=N;i++){
    if (i!=D)
      v.push_back(S[i]+P[N-2+i]);
  }
  sort(v.begin(),v.end());
  for (int i=0;i<v.size();i++)
    cnt[v[i]]++;
  for (int i=v.size()-1;i>=0;i++){
    if (S[D]+P[1]>=v[i]){
      cout<<v.size()+1-(i+cnt[S[D]+P[1]])<<endl;
      return 0;
    }
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,D;
int S[200001],P[200001];
map<int,int>cnt;
vector<int>v;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>D;
  for (int i=1;i<=N;i++)
    cin>>S[i];
  for (int i=1;i<=N;i++)
    cin>>P[i];
  for (int i=1;i<=N;i++){
    if (i!=D)
      v.push_back(S[i]+P[N-1+i]);
  }
  sort(v.begin(),v.end());
  for (int i=0;i<v.size();i++)
    cnt[v[i]]++;
  for (int i=v.size()-1;i>=0;i++){
    if (S[D]+P[1]>=v[i]){
      cout<<v.size()+1-(i+cnt[S[D]+P[1]])<<endl;
      return 0;
    }
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,D;
int S[200001],P[200001];
map<int,int>cnt;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>D;
  for (int i=1;i<=N;i++){
    cin>>S[i];
    if (i!=D)
      cnt[S[i]]++;
  }
  cin>>P[0];
  for (int i=1;i<=N;i++){
    if (S[D]+P[0]>=S[i]){
      cout<<i+cnt[S[D]+P[0]]<<endl;
      return 0;
    }
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,D;
int S[200001],P[200001];

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>D;
  for (int i=1;i<=N;i++)
    cin>>S[i];
  cin>>P[0];
  for (int i=1;i<=N;i++){
    if (S[D]+P[0]>=S[i]){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,D;
int S[200001],P[200001];
vector<int>v1,v2;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>D;
  int X=0;
  for (int i=1;i<=N;i++){
    cin>>S[i];
    if (i==D)
      X+=S[i];
    else
      v1.push_back(S[i]);
  }
  for (int i=1;i<=N;i++){
    cin>>P[i];
    if (i==1)
      X+=P[i];
    else
      v2.push_back(P[i]);
  }
  int L=0;
  int R=v2.size()-1;
  int place=1;
  for (int i=0;i<v1.size();i++){
    if (v1[i]+v2[R]>X){
      L++;
      place++;
    }
    else
      R--;
  }
  cout<<place<<endl;
  return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
PRII r[N];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];
	FORE(i,2,d-1) s[i] += p[n-i+2];
	//FORE(i,1,n) printf("...s%d:%d\n",i,s[i]);
	FORE(i,1,d){
		r[i-1].first = s[i];
		r[i-1].second = i;
	}
	sort(r,r+d);
	int q = d-1;
	while(r[q--].first > s[d]) ans++;
	printf("%d\n",ans+1);
    return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];

	ans = d-1;
	while(s[ans--] <= s[d] && ans == 0);
	ans += 1;
	//printf("%d\n",ans);
	int j = n;
	FORE(i,ans,d-1){
		//printf("...%d %d %d\n",s[i],p[j],s[d]);
		if(s[i]+p[j] > s[d]) ans++;
		else j--;
	}
	printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
int rank1[100000005];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];
	FORE(i,2,d-1) s[i] += p[n-i+2];
	//FORE(i,1,n) printf("...s%d:%d\n",i,s[i]);
	int mx = 0;
	FORE(i,1,d){
		rank1[s[i]]++;
		//mx = mx>s[i]?mx:s[i];
		if(mx < s[i]) mx = s[i];
	}
	//printf("...mx:%d\n",mx);
	FORE(i,s[d]+1,mx) ans += rank1[i];
	printf("%d\n",ans+1);
    return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	int j = n;
	if(d == 1){
		printf("1\n");
		goto ss;
	}
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];

	ans = d-1;
	while(s[ans--] <= s[d] && ans != 0);
	ans += 1;
	//printf("..%d\n",ans);

	FORE(i,ans,d-1){
		//printf("...%d %d %d\n",s[i],p[j],s[d]);
		if(s[i]+p[j] > s[d]) ans++;
		else j--;
	}
	printf("%d\n",ans);
ss:
    return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
int rank[100000005];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];
	FORE(i,2,d-1) s[i] += p[n-i+2];
	//FORE(i,1,n) printf("...s%d:%d\n",i,s[i]);
	int mx = 0;
	FORE(i,1,d){
		rank[s[i]]++;
		//mx = mx>s[i]?mx:s[i];
		if(mx < s[i]) mx = s[i];
	}
	//printf("...mx:%d\n",mx);
	FORE(i,s[d]+1,mx) ans += rank[i];
	printf("%d\n",ans+1);
    return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];

	ans = d-1;
	while(s[ans--] <= s[d] && ans != 0);
	ans += 1;
	//printf("..%d\n",ans);
	int j = n;
	FORE(i,ans,d-1){
		//printf("...%d %d %d\n",s[i],p[j],s[d]);
		if(s[i]+p[j] > s[d]) ans++;
		else j--;
	}
	printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); I++)
#define FORE(I,A,B) for(int I = (A); I <= (B); I++)
#define PRII pair<int,int>
#define LL long long

#define INF 1000000001
#define N 200005
using namespace std;
int n,d;
int s[N],p[N];
int ans;
int main()
{
    //freopen("datain.txt","r",stdin);
	cin >> n >> d;
	FORE(i,1,n) cin >> s[i];
	FORE(i,1,n) cin >> p[i];
	s[d] += p[1];

	ans = d-1;
	while(s[ans--] <= s[d] && ans == 0);
	ans += 1;
	printf("%d\n",ans);
	int j = n;
	FORE(i,ans,d-1){
		printf("...%d %d %d\n",s[i],p[j],s[d]);
		if(s[i]+p[j] > s[d]) ans++;
		else j--;
	}
	printf("%d\n",ans);
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <queue>

int n , d , b , sol , front , back , S[200010] , P[200010] , C[200010];

bool cmp(int a , int b)
{
	return a > b;
}

int main()
{

	scanf("%d%d" , &n , &d);
	for (int i = 1;i <= n;++i) scanf("%d" , &S[i]);
	for (int i = 1;i <= n;++i) scanf("%d" , &P[i]);
	b = S[d] + P[1];
	for (int i = d + 1;i <= n;++i) S[i - 1] = S[i];
	for (int i = 2;i <= n;++i) P[i - 1] = P[i];
	back = n;
	front = 1;
	for (int i = 1;i <= n - 1;++i)
	{
		if (S[i] + P[front] <= b)
		{
			C[i] = S[i] + P[front];
			++front;
		} else
		if (S[i] + P[back] <= b)
		{
			C[i] = S[i] + P[back];
			--back;
		} else
		{
			C[i] = S[i] + P[front];
			++front;
		}
	}
	C[n] = b;
	std::sort(C + 1 , C + n + 1 , cmp);
	sol = 1;
	for (int i = 2;(i <= n) && (C[i - 1] != b);++i) if (C[i - 1] != C[i]) ++sol;
	printf("%d" , sol);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <queue>

int n , d , b , sol , front , back , S[200010] , P[200010] , C[200010];

bool cmp(int a , int b)
{
    return a > b;
}

int main()
{

    scanf("%d%d" , &n , &d);
    for (int i = 1;i <= n;++i) scanf("%d" , &S[i]);
    for (int i = 1;i <= n;++i) scanf("%d" , &P[i]);
    b = S[d] + P[1];
    for (int i = d + 1;i <= n;++i) S[i - 1] = S[i];
    for (int i = 2;i <= n;++i) P[i - 1] = P[i];
    back = n - 1;
    front = 1;
    for (int i = 1;i <= n - 1;++i)
    {
        if (S[i] + P[front] <= b)
        {
            C[i] = S[i] + P[front];
            ++front;
        } else
        if (S[i] + P[back] <= b)
        {
            C[i] = S[i] + P[back];
            --back;
        } else
        {
            C[i] = S[i] + P[front];
            ++front;
        }
    }
    C[n] = b;
    std::sort(C + 1 , C + n + 1 , cmp);
    sol = 1;
    for (int i = 2;(i <= n) && (C[i - 1] != b);++i) ++sol;
    printf("%d" , sol);
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <queue>

int n , d , b , sol , front , back , S[200010] , P[200010] , C[200010];

bool cmp(int a , int b)
{
    return a > b;
}

int main()
{

    scanf("%d%d" , &n , &d);
    for (int i = 1;i <= n;++i) scanf("%d" , &S[i]);
    for (int i = 1;i <= n;++i) scanf("%d" , &P[i]);
    b = S[d] + P[1];
    for (int i = d + 1;i <= n;++i) S[i - 1] = S[i];
    for (int i = 2;i <= n;++i) P[i - 1] = P[i];
    back = n - 1;
    front = 1;
    for (int i = 1;i <= n - 1;++i)
    {
        if (S[i] + P[front] <= b)
        {
            C[i] = S[i] + P[front];
            ++front;
        } else
        if (S[i] + P[back] <= b)
        {
            C[i] = S[i] + P[back];
            --back;
        } else
        {
            C[i] = S[i] + P[front];
            ++front;
        }
    }
    C[n] = b;
    std::sort(C + 1 , C + n + 1 , cmp);
    sol = 1;
    for (int i = 2;(i <= n) && (C[i - 1] != b);++i) if (C[i - 1] != C[i]) ++sol;
    printf("%d" , sol);
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <queue>

int n , d , b , sol , front , back , S[200010] , P[200010] , C[200010];

bool cmp(int a , int b)
{
	return a > b;
}

int main()
{

	scanf("%d%d" , &n , &d);
	for (int i = 1;i <= n;++i) scanf("%d" , &S[i]);
	for (int i = 1;i <= n;++i) scanf("%d" , &P[i]);
	b = S[d] + P[1];
	for (int i = d + 1;i <= n;++i) S[i - 1] = S[i];
	for (int i = 2;i <= n;++i) P[i - 1] = P[i];
	for (int i = 1;i <= n - 1;++i)
	for (int i = 1;i <= n - 1;++i)
	{
		if (S[i] + P[front] <= d)
		{
			C[i] = S[i] + P[front];
			++front;
		} else
		if (S[i] + P[back] <= d)
		{
			C[i] = S[i] + P[back];
			--back;
		} else
		{
			C[i] = S[i] + P[front];
			++front;
		}
	}
	C[n] = b;
	std::sort(C + 1 , C + n + 1 , cmp);
	sol = 1;
	for (int i = 2;(i <= n) && (C[i - 1] != b);++i) if (C[i - 1] != C[i]) ++sol;
	printf("%d" , sol);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			if(s[i]+p[tot+1]==ww)
				jj++;
			else
			{
				sum=sum+jj;
				jj=1;
		    }
			ww=s[i]+p[tot+1];
		}
		else
		{
			a[gg]=0;
			gg++;
			ww=s[i]+p[gg];
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		if(i==n)
		{
			scanf("%d",&g);
		}
		else
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n);
	int ans=w+g;
	int tot=n-1;
	int gg=1;
	int sum=0;
	for(int i=n-1;i>=1;i--)
	{
		if(a[gg]==1)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			a[gg]=0;
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n+1);
	int w;
    w=s[d];
	for(int i=d;i<=n-1;i++)
	s[i]=s[i+1];
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			tot--;
			sum++;
		}
		else
		{
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n+1);
	int w;
	for(int i=1;i<=n;i++)
	{
		if(i==d)
		{
			w=s[i];
			break;
		}
	}
	for(int i=d;i<=n;i++)
	s[i]=s[i+1];
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			if(s[i]+p[tot+1]==ww)
				jj++;
			else
			{
				sum=sum+jj;
				jj=1;
		    }
			ww=s[i]+p[tot+1];
		}
		else
		{
			a[gg]=0;
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			if(s[i]+p[tot+1]==ww)
				jj++;
			else
			{
				sum=sum+jj;
				jj=1;
		    }
			ww=s[i]+p[tot+1];
		}
		else
		{
			a[gg]=0;
			gg++;
			ww=s[i]+p[gg-1];
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1;
	for(int i=n-1;i>=1;i--)
	{
		if(a[gg]==1)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			a[gg]=0;
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n+1);
	int w;
	for(int i=1;i<=n;i++)
	{
		if(i==d)
		{
			w=s[i];
			break;
		}
	}
	for(int i=d;i<=n-1;i++)
	s[i]=s[i+1];
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1;
	for(int i=n-1;i>=1;i--)
	{
		if(gg==tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			a[gg]=0;
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1;
	for(int i=n-1;i>=1;i--)
	{
		if(a[gg]==1||a[tot]==1)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			a[gg]=0;
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	int w;
	w=s[d];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n+1);
	for(int i=d;i<=n-1;i++)
	s[i]=s[i+1];
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			tot--;
			sum++;
		}
		else
		{
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			if(s[i]+p[tot+1]==ww)
				jj++;
			else
			{
				sum=sum+jj;
				jj=1;
		    }
			ww=s[i]+p[tot+1];
		}
		else
		{
			a[gg]=0;
			gg++;
			if(s[i]+p[gg-1]==ww)
				jj++;
			ww=s[i]+p[gg-1];
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n-1;i++)
	{
		if(i==d&&f==0)
		{
		scanf("%d",&g);
		i--;
		f=1;
	    }
		else
		scanf("%d",&s[i]);
	}
	int w=g;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			a[tot]=1;
			tot--;
			sum++;
		}
		else
		{
			a[gg]=0;
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[200001],p[200001];
bool a[200001];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int g;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	int w;
	w=s[d];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	for(int i=d;i<=n-1;i++)
	s[i]=s[i+1];
	sort(s+1,s+n);
	sort(p+1,p+n+1);
	int ans=w+p[n];
	int tot=n-1;
	int gg=1;
	int sum=1,jj=1,ww;
	for(int i=n-1;i>=1;i--)
	{
		if(gg>tot)
		break;
		if(s[i]+p[gg]>ans)
		{
			tot--;
			sum++;
		}
		else
		{
			gg++;
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n,d;
int S[200005];
int P[200005];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    for(int i=1;i<=n;i++){
        cin >> P[i];
    }
    S[d] += P[1];
    int pos = 2;
    for (int i = n;i>=1;i--){
        if (i==d)
            break;
        S[i]+=P[pos];
        pos++;
    }
    for (int i = 1; i < d;i++){
        S[i]+=P[pos];
        pos++;
    }
        int ans = 1;
    for(int i=1;i<=n;i++){
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int n,d;
long long S[200005];
long long P[200005];
int main(){
    set<int> s;
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    cin >> P[1];
    for(int i=2;i<=n;i++){
        cin >> P[i];
        s.insert(P[i]);
    }
    S[d] += P[1];
    for(int i=1;i<=n;i++){
        if(i==d) continue;
        if(*s.begin()+S[i]>S[d]){
            S[i]+=(*(s.rbegin()));
         //   cout << *s.rbegin() << endl;
            auto it = s.rbegin();
            s.erase(*it);
        } else{
            auto it = s.lower_bound(S[d] - S[i]);
            if(it==s.end())
                --it;
            else if(*it>S[d]-S[i])
                --it;
            S[i]+=*it;
            s.erase(*it);
        }
    }
    long long ans = 1;
    for(int i=1;i<=n;i++){
      //  cout << S[i] << " ";
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n,d;
int S[200005];
int P[200005];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    for(int i=1;i<=n;i++){
        cin >> P[i];
    }
    S[d] += P[1];
    int pos = 2;
    for (int i = n;i>=1;i--){
        if (i==d)
            continue;
        S[i]+=P[pos];
        pos++;
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(S[i]>=S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n,d;
int S[200005];
int P[200005];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    for(int i=1;i<=n;i++){
        cin >> P[i];
    }
    S[d] += P[1];
    int pos = 2;
    for (int i = n;i>d;i--){
        S[i]+=P[pos];
        pos++;
    }
    for (int i = 1; i < d;i++){
        S[i]+=P[pos];
        pos++;
    }
        int ans = 1;
    for(int i=1;i<=n;i++){
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n,d;
int S[200005];
int P[200005];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    for(int i=1;i<=n;i++){
        cin >> P[i];
    }
    S[d] += P[1];
    int pos = 2;
    for (int i = n;i>=1;i--){
        if (i==d)
            continue;
        S[i]+=P[pos];
        pos++;
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n,d;
long long S[200005];
long long P[200005];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    for(int i=1;i<=n;i++){
        cin >> P[i];
    }
    S[d] += P[1];
    int pos = 2;
    for (int i = n; i > d;i--){
        S[i]+=P[pos];
        pos++;
    }
    for (int i = 1; i < d;i++){
        S[i]+=P[pos];
        pos++;
    }
    long long ans = 1;
    for(int i=1;i<=n;i++){
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int n,d;
long long S[200005];
long long P[200005];
int main(){
    multiset<int> s;
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    cin >> P[1];
    for(int i=2;i<=n;i++){
        cin >> P[i];
        s.insert(P[i]);
    }
    S[d] += P[1];
    for(int i=1;i<=n;i++){
        if(i==d) continue;
        if(*s.begin()+S[i]>S[d]){
            auto it = s.end();
            --it;
            S[i]+=(*it);
            s.erase(it);
        }else{
            auto it = s.lower_bound(S[d] - S[i]);
            if(it==s.end())
                --it;
            else if(*it>S[d]-S[i] && it!=s.begin())
                --it;
            S[i]+=*it;
            s.erase(it);
        }
    }
    long long ans = 1;
    for(int i=1;i<=n;i++){
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int n,d;
long long S[200005];
long long P[200005];
int main(){
    multiset<int> s;
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin >> S[i];
    }
    cin >> P[1];
    for(int i=2;i<=n;i++){
        cin >> P[i];
        s.insert(P[i]);
    }
    S[d] += P[1];
    for(int i=1;i<=n;i++){
        if(i==d) continue;
        if(*s.begin()+S[i]>S[d]){
            auto it = s.rbegin();
            S[i]+=(*it);
            s.erase(*it);
        }else{
            auto it = s.lower_bound(S[d] - S[i]);
            if(it==s.end())
                --it;
            else if(*it>S[d]-S[i] && it!=s.begin())
                --it;
            S[i]+=*it;
            s.erase(*it);
        }
    }
    long long ans = 1;
    for(int i=1;i<=n;i++){
        if(S[i]>S[d])
            ans++;
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
vector<int>a,b;
int main()
{
	int n,d,cur,cnt,sum=0;
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(i==d)
			cur=x;
		else
			a.push_back(x);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		b.push_back(x);
	}
	sort(b.begin(),b.end());
	cnt=b[b.size()-1];
	b.pop_back();
	cur+=cnt;
	for(int i=0;i<a.size();i++)
	{
		int k=a[i];
		if(k+b[0]>cur)
		{
			b.pop_back();
			sum++;
			continue;
		}
		if(k<b[b.size()-1])
			break;
		auto w=lower_bound(b.begin(),b.end(),k-cur);
		b.erase(w);
	}
	printf("%d\n",sum+1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int>a,b;
int main()
{
	int n,d,cur,cnt,sum=0;
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(i==d)
			cur=x;
		else
			a.push_back(x);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		b.push_back(x);
	}
	sort(b.begin(),b.end());
	cnt=b[b.size()-1];
	b.pop_back();
	cur+=cnt;
	int lb=0,ub=b.size()-1;
	for(int i=0;i<a.size();i++)
	{
		int k=a[i];
		if(k+b[lb]>cur)
		{
			ub--;
			sum++;
			continue;
		}
		else
			lb++;
	}
	printf("%d\n",sum+1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int>a,b;
int main()
{
	int n,d,cur,cnt,sum=0;
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(i==d)
			cur=x;
		else
			a.push_back(x);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		b.push_back(x);
	}
	sort(b.begin(),b.end());
	cnt=b[b.size()-1];
	b.pop_back();
	cur+=cnt;
	for(int i=0;i<a.size();i++)
	{
		int k=a[i];
		if(k+b[0]>cur)
		{
			b.pop_back();
			cerr<<"!"<<k+b[0]<<endl;
			sum++;
			continue;
		}
		auto w=lower_bound(b.begin(),b.end(),k-cur);
		cerr<<*w<<endl;
		b.erase(w);
	}
	printf("%d\n",sum+1);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct Node{
	int x, num;
	Node(){}
	Node(int a, int b){x = a, num = b;}
	bool operator < (const Node &A) const{
		return x < A.x;
	}
}a[100010], ans[100010];

vector <Node> b;

bool cmp(Node a, Node b){
	return a.x > b.x;
}

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	k--;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i].x);
		a[i].num = i, ans[i] = a[i];
	}
	for (int i = 0; i < n; i++){
		b.push_back(Node(0, 0));
		scanf("%d", &b[i].x);
		b[i].num = i;
	}
	sort(a, a + n, cmp), sort(b.begin(), b.end());
	ans[k].x += b[b.size() - 1].x;
	b.erase(b.end() - 1);
	for (int i = 0; i < n; i++){
		if (a[i].num == k) continue;
		int pos = upper_bound(b.begin(), b.end(), Node(ans[k].x - ans[a[i].num].x, 0)) - b.begin() - 1;
		if (pos == -1) ans[a[i].num].x += b[b.size() - 1].x, b.erase(b.end() - 1);
		else ans[a[i].num].x += b[pos].x, b.erase(b.begin() + pos);
	}
	sort(ans, ans + n, cmp);
	for (int i = 0; i < n; i++){
		if (ans[i].num == k){
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
int n,d,s[200001],p[200001],x,ans;
int main()
{
	cin>>n>>d;
	for (int i=0;i<n;i++)
	{
		cin>>s[i];
		if (i+1==d) x=s[i];
	}
	for (int i=0;i<n;i++) cin>>p[i];
	x+=p[0];
	for (int i=0;i<d;i++)
	{
		if (s[i]+p[n-1]<=x)
		{
			ans=i+1;
			break;
		}
	}
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
int n,d,s[200001],p[200001],x,ans;
int main()
{
	cin>>n>>d;
	for (int i=0;i<n;i++)
	{
		cin>>s[i];
		if (i+1==d) x=s[i];
	}
	for (int i=0;i<n;i++) cin>>p[i];
	x+=p[0];
	for (int i=0;i<n;i++)
	{
		if (s[i]+p[n-1]<=x && s[n-1]+p[1]<=x)
		{
			ans=i+1;
			break;
		}
	}
	cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long n,d,s[200005],p[200005],c[200005],sMax;

long long Search(long long s[],long long l, long long r, long long smax){
        long long mid, imax =d;
        while (l <r){
            mid =(l+r)/2;
            if (smax > s[mid]){
                imax = mid;
                r = mid-1;
            }
            else if (smax < s[mid]){
                l=mid+1;
            } else return imax = mid;;
        }
        if (l == r) if (smax >= s[l]) imax =l;
        int i=2;
        while (smax < c[i]+p[n-1]) i++;
        return imax+i-2;
    }

int main(){
    cin >> n >> d;
    for (int i=1;i<=n;i++) cin >> s[i];
    for (int i=1;i<=n;i++) cin >> p[i];
    sMax = s[d] + p[1];
    for (int i=1;i<=n;i++)
    {
        c[i]=s[i];
        s[i]=s[i]+p[n];
    }
    cout << Search(s,1,n,sMax);
}


#include <bits/stdc++.h>

using namespace std;

long long n,d,s[200005],p[200005],sMax;

long long Search(long long s[],long long l, long long r, long long smax){
        long long mid, imax =d;
        while (l <r){
            mid =(l+r)/2;
            if (smax > s[mid]){
                imax = mid;
                r = mid-1;
            }
            else if (smax < s[mid]){
                l=mid+1;
            } else return mid;
        }
        if (l == r) if (smax >= s[l]) imax =l;
        return imax;
    }

int main(){
    cin >> n >> d;
    for (int i=1;i<=n;i++) cin >> s[i];
    for (int i=1;i<=n;i++) cin >> p[i];
    sMax = s[d] + p[1];
    for (int i=1;i<=n;i++) s[i]=s[i]+p[n];
    cout << Search(s,1,n,sMax);
}


#include <bits/stdc++.h>

using namespace std;

long long n,d,s[200005],p[200005],sMax;

long long Search(long long s[],long long l, long long r, long long smax){
        long long mid, imax =d;
        while (l <r){
            mid =(l+r)/2;
            if (smax > s[mid]){
                imax = mid;
                r = mid-1;
            }
            else if (smax < s[mid]){
                l=mid+1;
            } else return mid-1;
        }
        if (l == r) if (smax > s[l]) imax =l;
        return imax;
    }

int main(){
    cin >> n >> d;
    for (int i=1;i<=n;i++) cin >> s[i];
    for (int i=1;i<=n;i++) cin >> p[i];
    sMax = s[d] + p[1];
    for (int i=1;i<=n;i++) s[i]=s[i]+p[n];
    cout << Search(s,1,n,sMax);
}


#include <bits/stdc++.h>

using namespace std;

long long n,d,s[200005],p[200005],c[200005],sMax;

long long Search(long long s[],long long l, long long r, long long smax){
        long long mid, imax =d;
        while (l <r){
            mid =(l+r)/2;
            if (smax > s[mid]){
                imax = mid;
                r = mid-1;
            }
            else if (smax < s[mid]){
                l=mid+1;
            } else return imax = mid;;
        }
        if (l == r) if (smax >= s[l]) imax =l;
        int i=imax+1;
        while (smax < c[i]+p[n-1]) i++;
        return imax+i-imax-1;
    }

int main(){
    cin >> n >> d;
    for (int i=1;i<=n;i++) cin >> s[i];
    for (int i=1;i<=n;i++) cin >> p[i];
    sMax = s[d] + p[1];
    for (int i=1;i<=n;i++)
    {
        c[i]=s[i];
        s[i]=s[i]+p[n];
    }
    cout << Search(s,1,n,sMax);
}


#include <bits/stdc++.h>

using namespace std;

long long n, d, dT;
long long s[200005],p[200005];

int main(){
    cin >> n >> d;
    for (int i=0;i<n;i++) cin >> s[i];
    for (int i=0;i<n;i++) cin >> p[i];
    sort(p, p+n);
    dT= s[d-1]+p[n-1];
    s[d]=-99999;
    sort(s, s+n, greater<int>());
    int i=0;
    while (dT < s[i]+p[0]) i++;
    cout << i+1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long n,d,s[200005],p[200005],sMax;

long long Search(long long s[],long long l, long long r, long long smax){
        long long mid, imax =d;
        while (l != r){
            mid =(l+r)/2;
            if (smax > s[mid]){
                imax = mid;
                r = mid-1;
            }
            else if (smax < s[mid]){
                l=mid+1;
            } else return mid;

            if (l==r) break;
        }

        if (l == r) if (smax >= s[l]) imax =l;
        return imax;
    }

int main(){
    cin >> n >> d;
    for (int i=1;i<=n;i++) cin >> s[i];
    for (int i=1;i<=n;i++) cin >> p[i];
    sMax = s[d] + p[1];
    for (int i=1;i<=n;i++) s[i]=s[i]+p[n];
    cout << Search(s,1,n,sMax);
}


#include <bits/stdc++.h>

using namespace std;

long long n,d,s[200005],p[200005],c[200005],sMax;

long long Search(long long s[],long long l, long long r, long long smax){
        long long mid, imax =d;
        while (l <r){
            mid =(l+r)/2;
            if (smax > s[mid]){
                imax = mid;
                r = mid-1;
            }
            else if (smax < s[mid]){
                l=mid+1;
            } else return imax = mid;;
        }
        if (l == r) if (smax >= s[l]) imax =l;
        int i=2;
        while (smax < c[i]+p[2]) i++;
        return imax+i-2;
    }

int main(){
    cin >> n >> d;
    for (int i=1;i<=n;i++) cin >> s[i];
    for (int i=1;i<=n;i++) cin >> p[i];
    sMax = s[d] + p[1];
    for (int i=1;i<=n;i++)
    {
        c[i]=s[i];
        s[i]=s[i]+p[n];
    }
    cout << Search(s,1,n,sMax);
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=200020;
int n,d,i,k;
int s[maxn],p[maxn];
int main()
{
	std::cin>>n>>d;
	for(i=0;i<n;++i)
		std::cin>>s[i];
	for(k=0;k<n;++k)
		std::cin>>p[k];
	for(register int i=0;i<=d;++i)
	{
		if(s[d]+p[i]>=s[i]+p[i])
		{
			if(i-1<0)
			{
				i=1,cout<<i;
				return 0;
			}
			cout<<i-1;
			return 0;
		}
		else
		continue;
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=200020;
int n,d,i,k;
int s[maxn],p[maxn];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	std::cin>>n>>d;
	for(i=0;i<n;++i)
		std::cin>>s[i];
	for(k=0;k<n;++k)
		std::cin>>p[k];
	sort(s,s+n,cmp);
	sort(p,p+n,cmp);
		for(register int x=0;x<=d;x++)
		{
			if(s[d-1]+p[x]==s[x]+p[x+1])
			{
				cout<<x+1;
				return 0;
			}
				if(s[d-1]+p[x]>s[x]+p[x+1])
			{
				cout<<x;
				return 0;
			}
			else
			{
			continue;
			}
		}
}


#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=100000000;
int n,d,i,k,j;
int s[maxn],p[maxn];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d %d",&n,&d);
	while(n--)
	{
		for(i=1;i<n;i++)
			scanf("%d ",&s[i]);
		for(k=1;k<n;k++)
			scanf("%d ",&p[k]);
		sort(s,s+n,cmp);
		sort(p,p+n,cmp);
		for(j=1;j<d;j++)
			{
				if(s[d]+p[j]<s[j]+p[j+1])
				continue;
				else if(s[d]+p[j]>=s[j]+p[j+1])
				printf("%d",j);
				return 0;
			}
}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=100000006;
int n,d,i,k,j;
int s[maxn],p[maxn];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	std::cin>>n>>d;
	while(true)
	{
	for(i=1;i<=n;++i)
		std::cin>>s[i];
	for(k=1;k<=n;++k)
		std::cin>>p[k];
	sort(s,s+n,cmp);
	sort(p,p+n,cmp);
	for(j=1;j<=d;++j)
		{
			if(s[d]+p[j]<s[j]+p[j+1])continue;
			else cout<<j;
			return 0;
		}
}
}


#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int n,d,i,k,j;
int s[200000],p[200000];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d %d",&n,&d);
	while(n--)
	{
		for(i=1;i<=n;i++)
			scanf("%d ",&s[i]);
		for(k=1;k<=n;k++)
			scanf("%d ",&p[k]);
		sort(s,s+n,cmp);
		sort(p,p+n,cmp);
		for(j=1;j<=d;j++)
			{
				if(s[d]+p[j]<s[j]+p[j+1])
				continue;
				else if(s[d]+p[j]==s[j]+p[j+1])
				printf("%d",j+1);
				else
				printf("%d",j);
				return 0;
			}
}
}


#include<bits/stdc++.h>
using namespace std;
int n,d,ans=0;
int s[200005],p[200005];
int main()
{
    std::cin>>n>>d;
    for(int i=1;i<=n;i++)
        std::cin>>s[i];
    for(int i=1;i<=n;i++)
        std::cin>>p[i];
        sort(p+1,p+1+n);
        int j=1;
    for(int i=1;i<d;i++)
        if(s[i]+p[j]>s[d]+p[n])	ans++;
        else j++;
    cout<<ans+1<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,ans=0;
bool cmp(int x,int y)
{
	return x>y;
}
int s[200005],p[200005];
int main()
{
	std::cin>>n>>d;
	for(int i=1;i<=n;i++)
		std::cin>>s[i];
	for(int i=1;i<=n;i++)
		std::cin>>p[i];
		sort(p+1,p+1+n);
		int j;
	for(int i=1;i<d;i++)
		{
		if(s[i]+p[j]>s[d]+p[n])
			ans++;
		else j++;
	}
	cout<<ans+1<<endl;
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
int n,d,ans=0;
int s[200005],p[200005];
int main()
{
	std::cin>>n>>d;
	for(int i=1;i<=n;i++)
		std::cin>>s[i];
	for(int i=1;i<=n;i++)
		std::cin>>p[i];
		sort(p+1,p+1+n);
		int j=1;
	for(int i=1;i<d;i++)
		if(s[i]+p[j]>s[d]+p[n])	ans++;
		else j++;
	cout<<ans+1<<endl;
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn=200020;
int n,d,i,k;
int s[maxn],p[maxn];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	std::cin>>n>>d;
	for(i=1;i<=n;++i)
		std::cin>>s[i];
	for(k=1;k<=n;++k)
		std::cin>>p[k];
	sort(s,s+n+1,cmp);
	sort(p,p+n+1,cmp);
	if(s[d-1]+p[0]>=s[0]+p[1])cout<<"1";
	else
	{
		for(register int x=1;x<=d;x++)
		{
			if(s[d-1]+p[x]>=s[x]+p[x+1])
			{
				cout<<x;
				return 0;
			}
			else
			{
			continue;
			}
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,d,ans=0;
bool cmp(int x,int y)
{
	return x>y;
}
int s[200005],p[200005];
int main()
{
	std::cin>>n>>d;
	for(int i=1;i<=n;i++)
		std::cin>>s[i];
	for(int i=1;i<=n;i++)
		std::cin>>p[i];
		sort(p+1,p+1+n);
		int j;
	for(int i=1;i<d;i++)
		if(s[i]+p[j]>s[d]+p[n])
			ans++;
		else j++;
	cout<<ans+1<<endl;
	return 0;

}


#include<cstdio>//CF1046C
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

const int N=2e5+5;

int n,d,s[N],p[N],visp[N],ans,fa[N],luogu;

int find(int u){
	if(u==fa[u]){
		return fa[u];
	}
	return fa[u]=find(fa[u]);
}

int bs(int l,int r,int u){
	if(l==r){
		return l;
	}
	int mid=(l+r)>>1;
	if(p[mid]<=u){
		return bs(l,mid,u);
	}
	else{
		return bs(mid+1,r,u);
	}
}

void pre(){
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
}

void merge(int u,int v){
	fa[find(u)]=find(v);
}

int main(){
	scanf("%d",&n);
	scanf("%d",&d);
	pre();
	if(n==1){
		printf("1\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&s[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
	}
	p[1]+=s[d];
	for(int i=1;i<d;i++){
		int poi=bs(2,n+1,p[1]-s[i]);
		if(fa[poi]==0){
			ans++;
		}
		else{
			merge(poi,poi+1);
		}
	}
	printf("%d\n",ans+1);
	return 0;
}


#include<cstdio>//CF1046C
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

const int N=2e5+5;

int n,d,s[N],p[N],visp[N],ans,fa[N];

int find(int u){
	if(u==fa[u]){
		return fa[u];
	}
	return fa[u]=find(fa[u]);
}

int bs(int l,int r,int u){
	if(l==r){
		return l;
	}
	int mid=(l+r)>>1;
	if(p[mid]<=u){
		return bs(l,mid,u);
	}
	else{
		return bs(mid+1,r,u);
	}
}

void pre(){
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
}

void merge(int u,int v){
	fa[find(u)]=find(v);
}

int main(){
	scanf("%d",&n);
	scanf("%d",&d);
	pre();
	if(n==1){
		printf("1\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&s[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
	}
	p[1]+=s[d];
	for(int i=1;i<d;i++){
		int poi=bs(2,n+1,p[1]-s[i]);
		if(fa[poi]==0){
			ans++;
		}
		else{
			merge(poi,poi+1);
		}
	}
	printf("%d\n",ans+1);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#define MAXN 200010
using namespace std;
int n,k,maxx;
int a[MAXN],sc[MAXN];
bool check(int mid)
{
	int cnt=n+1;
	bool flag=true;
	for(int i=mid;i<=k-1;i++)
	{
		if(sc[--cnt]+a[i]>maxx)
		{
			flag=false;
			break;
		}
	}
	if(flag==false) return false;
	else return true;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&sc[i]);
	int l=1,r=k-1;
	maxx=a[k]+sc[1];
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#define MAXN 210010
using namespace std;
int n,k,maxx;
int a[MAXN],sc[MAXN];
bool check(int mid)
{
	int cnt=n+1;
	bool flag=true;
	int cur=sc[n]+a[mid];
	for(int i=mid;i<=k-1;i++)
	{
		if(sc[--cnt]+a[i]>maxx)
		{
			flag=false;
			break;
		}
		if(sc[cnt]+a[i]<=cur) break;
	}
	if(flag==false) return false;
	else return true;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&sc[i]);
	int l=1,r=k;
	maxx=a[k]+sc[1];
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}


#include <cstdio>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

vector<LL> ve;
set<LL> ss;

int main()
{
	LL n, m;
	scanf("%lld%lld", &n, &m);
	LL now;
	ve.clear();
	ss.clear();
	for(LL i = 1; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		if(i == m)
			now = t;
		else
			ve.push_back(t);
	}
	LL t;
	scanf("%lld", &t);
	now += t;
	for(LL i = 2; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		if(n >= 200000)
			printf("%lld ", t);
		ss.insert(t);
	}
	LL ans = 1;
	LL tmp = 0;
	while(tmp < (LL) ve.size() && ve[tmp] > now)
	{
		ans++;
		set<LL>::iterator it = ss.end();
		--it;
		ss.erase(it);
		tmp++;
	}
//	cout << "ans = " << ans << endl;
//	cout << "size = " << ss.size() << endl;
//	cout << "tmp = " << tmp << endl;
//	cout << n << endl;
	for(LL i = ve.size() - 1; !ss.empty() && i >= tmp; --i)
	{
//		cout << i << ' ' << ss.size() << endl;
//		cout << now << ' ' << ve[i] << ' ' << (*it) << endl;
		set<LL>::iterator it = ss.begin();
		if(ve[i] + *(it) > now)
		{
			it = ss.end();
			--it;
			ss.erase(it);
			ans++;
		}
		else
		{
			it = ss.lower_bound(now - ve[i]);
			if(it != ss.begin())
				it--;
			ss.erase(it);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <cstdio>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

vector<LL> ve;
set<LL> ss;

int main()
{
	LL n, m;
	scanf("%lld%lld", &n, &m);
	LL now;
	ve.clear();
	ss.clear();
	for(LL i = 1; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		if(i == m)
			now = t;
		else
			ve.push_back(t);
	}
	LL t;
	scanf("%lld", &t);
	now += t;
	for(LL i = 2; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		ss.insert(t);
	}
	if(n >= 200000)
	{
		for(auto it = ss.begin(); it != ss.end(); ++it)
		{
			printf("%lld ", *it);
		}
	}
	LL ans = 1;
	LL tmp = 0;
	while(tmp < (LL) ve.size() && ve[tmp] > now)
	{
		ans++;
		set<LL>::iterator it = ss.end();
		--it;
		ss.erase(it);
		tmp++;
	}
//	cout << "ans = " << ans << endl;
//	cout << "size = " << ss.size() << endl;
//	cout << "tmp = " << tmp << endl;
//	cout << n << endl;
	for(LL i = ve.size() - 1; !ss.empty() && i >= tmp; --i)
	{
//		cout << i << ' ' << ss.size() << endl;
//		cout << now << ' ' << ve[i] << ' ' << (*it) << endl;
		set<LL>::iterator it = ss.begin();
		if(ve[i] + *(it) > now)
		{
			it = ss.end();
			--it;
			ss.erase(it);
			ans++;
		}
		else
		{
			it = ss.lower_bound(now - ve[i]);
			if(it != ss.begin())
				it--;
			ss.erase(it);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <cstdio>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

vector<LL> ve;
set<LL> ss;

int main()
{
	LL n, m;
	scanf("%lld%lld", &n, &m);
	LL now;
	ve.clear();
	ss.clear();
	for(LL i = 1; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		if(i == m)
			now = t;
		else
			ve.push_back(t);
	}
	LL t;
	scanf("%lld", &t);
	now += t;
	for(LL i = 2; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		ss.insert(t);
	}
	LL ans = 1;
	LL tmp = 0;
	while(tmp < (LL) ve.size() && ve[tmp] >= now)
	{
		ans++;
		set<LL>::iterator it = ss.end();
		--it;
		ss.erase(it);
		tmp++;
	}
//	cout << "ans = " << ans << endl;
//	cout << "size = " << ss.size() << endl;
//	cout << "tmp = " << tmp << endl;
//	cout << n << endl;
	for(LL i = ve.size() - 1; !ss.empty() && i >= tmp; --i)
	{
//		cout << i << ' ' << ss.size() << endl;
//		cout << now << ' ' << ve[i] << ' ' << (*it) << endl;
		set<LL>::iterator it = ss.begin();
		if(ve[i] + *(it) >= now)
		{
			it = ss.end();
			--it;
			ss.erase(it);
			ans++;
		}
		else
		{
			it = ss.lower_bound(now - ve[i]);
			if(it != ss.begin())
				it--;
			ss.erase(it);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <cstdio>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

vector<LL> ve;
multiset<LL> ss;

int main()
{
	LL n, m;
	scanf("%lld%lld", &n, &m);
	LL now;
	ve.clear();
	ss.clear();
	for(LL i = 1; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		if(i == m)
			now = t;
		else
			ve.push_back(t);
	}
	LL t;
	scanf("%lld", &t);
	now += t;
	for(LL i = 2; i <= n; ++i)
	{
		LL t;
		scanf("%lld", &t);
		ss.insert(t);
	}
	LL ans = 1;
	LL tmp = 0;
	while(tmp < (LL) ve.size() && ve[tmp] > now)
	{
		ans++;
		set<LL>::iterator it = ss.end();
		--it;
		ss.erase(it);
		tmp++;
	}
//	cout << "ans = " << ans << endl;
//	cout << "size = " << ss.size() << endl;
//	cout << "tmp = " << tmp << endl;
//	cout << n << endl;
	for(LL i = ve.size() - 1; !ss.empty() && i >= tmp; --i)
	{
//		cout << i << ' ' << ss.size() << endl;
//		cout << now << ' ' << ve[i] << ' ' << (*it) << endl;
		set<LL>::iterator it = ss.begin();
		if(ve[i] + *(it) > now)
		{
			it = ss.end();
			--it;
			ss.erase(it);
			ans++;
		}
		else
		{
			it = ss.lower_bound(now - ve[i]);
			if(it != ss.begin())
				it--;
			ss.erase(it);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int x;
int n,m;
int a[maxn];
int b[maxn];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    x=a[m];
    sort(a+1,a+n+1,cmp);
    sort(b+1,b+n+1,cmp);
    int cnt=m;
    for(int i=1; i<=n; i++)
    {
        if(a[i]==x) {cnt=i;break;}
    }
    x+=b[1];
    int y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    int c=n-m+1+y-1;
    //cout<<y<<endl;
    for(int i=m-1; i>y-1; i--)
    {
        //cout<<c+1<<endl;
        if(a[i]+b[++c]<=x) cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int x;
int n,m;
int a[maxn];
int b[maxn];

int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    x=a[m]+b[1];
    int cnt=m;
    int y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    int c=n-m+1+y-1;
    //cout<<y<<endl;
    for(int i=m-1; i>y-1; i--)
    {
        cout<<c+1<<endl;
        if(a[i]+b[++c]<x) cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int x;
int n,m;
int a[maxn];
int b[maxn];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    sort(a+1,a+n+1,cmp);
    sort(b+1,b+n+1,cmp);
    x=a[m]+b[1];
    int cnt=m;
    int y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    int c=n-m+1+y-1;
    //cout<<y<<endl;
    for(int i=m-1; i>y-1; i--)
    {
        //cout<<c+1<<endl;
        if(a[i]+b[++c]<=x) cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int x;
int n,m;
int a[maxn];
int b[maxn];

int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    x=a[m]+b[1];
    int cnt=m;
    int y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    int c=n-m+1+y-1;
    //cout<<y<<endl;
    for(int i=m-1; i>y-1; i--)
    {
        //cout<<c+1<<endl;
        if(a[i]+b[++c]<x) cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int x;
int n,m;
int a[maxn];
int b[maxn];

int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    x=a[m]+b[1];
    int cnt=m;
    int y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    int c=n-m+1+y-1;
    //cout<<y<<endl;
    for(int i=m-1; i>y-1; i--)
    {
        if(a[i]+b[++c]<=x) cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int n,m;
int a[maxn];
int b[maxn];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    cin>>n>>m;
    int cnt=1,id=n;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    int x;x=a[m]+b[1];
    for(int i=1; i<m; i++)
    {
        if(a[i]>x||a[i]+b[id]>x) cnt++;
        else id--;
    }
    printf("%d\n",cnt);
    return 0;
}
/*
4 2
29 28 13 9
1 1 1 0
*/


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll x;
ll n,m;
ll a[maxn];
ll b[maxn];

int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%I64d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%I64d",b+i);
    x=a[m]+b[1];
    ll cnt=m;
    ll y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    ll c=n-m+1+y-1;
    //cout<<y<<endl;
    for(int i=m-1; i>y-1; i--)
    {
        //cout<<c+1<<endl;
        if(a[i]+b[++c]<=x) cnt--;
    }
    printf("%I64d\n",cnt);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int x;
int n,m;
int a[maxn];
int b[maxn];

int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%d",a+i);
    for(int i=1; i<=n; i++)
        scanf("%d",b+i);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    x=a[m]+b[1];
    int cnt=m;
    int y;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<x) {y=i;break;}
    }
    int c=n-m+1+y-1;
    //cout<<y<<endl;
    1
    for(int i=m-1; i>y-1; i--)
    {
        //cout<<c+1<<endl;
        if(a[i]+b[++c]<=x) cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int last[200001],s[200001],n,d,p[200001],nxt[200001];
bool q[200001];
int find(int x)
{
	return (lower_bound(p+n-d+2,p+1+n,x,greater<int>() )-p);//第一个小于x的p[i]
}
int main()
{
    freopen(".in","r",stdin);
	cin>>n>>d;
	for(int i=1;i<=n;i++) cin>>s[i],last[i]=i-1,nxt[i]=i+1;
	for(int i=1;i<=n;i++) cin>>p[i];
	int f=s[d]+p[1];
	for(int i=d-1;i>=1;i--){
		int x=f-s[i];
		int k=find(x);
		while(q[k]){
			k=nxt[k];
		}
		if(p[k]>x||(k>n)){
			cout<<i+1;return 0;
		}
		q[k]=1;
		last[nxt[k]]=last[k];
		nxt[last[k]]=nxt[k];
		if(k==n){
			cout<<i;
			return 0;
		}
	}
	cout<<1;
}


#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
//
#define MAXN 210010
using namespace std;
int n,k,maxx;
int a[MAXN],sc[MAXN];
bool check(int mid)
{
	int cnt=n+1;
	//cout<<"mid="<<mid<<endl;
	bool flag=true;
	int cur=sc[n]+a[mid];
	for(int i=mid;i<=k-1;i++)
	{
		//printf("sc[%d]=%d a[%d]=%d maxx=%d\n",cnt-1,sc[cnt-1],i,a[i],maxx);
		if(sc[--cnt]+a[i]>maxx)
		{
			flag=false;
			break;
		}
		//if(sc[cnt]+a[i]<=cur) break;
	}
	if(flag==false) return false;
	else return true;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&sc[i]);
	int l=1,r=k;
	maxx=a[k]+sc[1];
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#define N 200100
using namespace std;
long long n,d;
long long ans,x;
long long s[N],p[N];
int main()
{
	scanf("%d%d", &n, &d);
	ans = d;
	for(int i=1; i<=n; i++) scanf("%d", &s[i]);
	for(int i=1; i<=n; i++) scanf("%d", &p[i]);
	for(int i = d - 1; i>=1; i--)
	{
		while(s[i] + p[x] > s[d] + p[1] && x <= n) x++;
		if(x > n) break;
		ans--, x++;
	}
	printf("%d\n", ans);
}


#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <climits>
#include <functional>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))	        \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int			g_nPeopleArrays[200010];
int			g_nNumberArrays[200010];

int main(int argc, char* argv[])
{
	int			nPeopleCount;
	int			nNumber;
	int			nIndex;
	int			nCount					= 0;

	cin >> nPeopleCount >> nNumber;

	for (int i = 1; i <= nPeopleCount; i++)
	{
		cin >> g_nPeopleArrays[i];
	}

	for (int i = 1; i <= nPeopleCount; i++)
	{
		cin >> g_nNumberArrays[i];
	}

	g_nPeopleArrays[nNumber] += g_nNumberArrays[1];
	nIndex = 2;
	for (int i = nNumber - 1; i >= 1; i--)
	{
		for (int j = nIndex; j <= nPeopleCount; j++)
		{
			if (g_nPeopleArrays[nNumber] >= g_nPeopleArrays[i] + g_nNumberArrays[j])
			{
				nCount++;
				nIndex = j + 1;
				break;
			}
		}
	}

	cout << nNumber - nCount << endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[300001],n,d,p[300001],t,ans;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++) cin>>p[i];
	for(int i=d-1;i>0;--i){
        while((s[i]+p[t]>=s[d]+p[1])&&t<=n) ++t;
        if(t>n) break;
        ++t;++ans;
	}
	cout<<d-ans;
}


#include<iostream>
#include<algorithm>
using namespace std;
int a[200005],b[200005];
int main ( )
{
	int n,m,i,k=1,t,j,q=0;;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	    cin>>a[i];
	for(i=1;i<=n;i++)
	    cin>>b[i];
	a[m]+=b[1];
	for(i=1;i<=n;i++)
	   if(a[i]<=a[m])
	   {
	   	j=i;
	   	break;
	   }
	t=j;
	for(i=m-1;i>=j;i--)
	{
		if(a[i]+b[n+t-m-1]<=a[m])
		    t++;
		while(a[i]+b[n+t-m-1]>a[m]&&t<=n)
		    t++;
	    if(t>n)
	      break;
	    q++;
	}
	cout<<m-q;
	return 0;
}


#include<cstdio>
#define r read()
using namespace std;
int s[200010],p[200010];
int read()
{
    int x=0,w=1;
	char c=getchar();
    for(;c^'-'&&(c<'0'||c>'9');c=getchar());
    if(c=='-')w=-1,c=getchar();
    for(;c>='0'&&c<='9';c=getchar())
	    x=(x<<3)+(x<<1)+c-'0';
	return x*w;
}
int main()
{
    int N=r,Ans=r,D=Ans,st(2);
    for(int i=1;i<=N;i++)
	    s[i]=r;
    for(int i=1;i<=N;i++)
	    p[i]=r;
    for(int i=D-1;i>0;i--)
	{
        while(s[i]+p[st]>s[D]+p[1]&&st<=N)++st;
        if(st>N)break;
        --Ans,++st;
    }
    printf("%d",Ans);
    return 0;
}


#pragma GCC optimize(2)
#include "cstdio"
using namespace std;
const int N=200000+5;
int n, d, s[N], p[N], over;
signed main()
{
	scanf("%d %d", &n, &d);
	for(register int i=1; i<=n; ++i) scanf("%d", &s[i]);
	for(register int i=1; i<=n; ++i) scanf("%d", &p[i]);
	s[d]+=p[1];
	for(register int i=2, j=d-1; i<=n && j; ++i)
		if(s[j]+p[i] <= s[d]) ++over, --j;
	printf("%d", d-over);
}


#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
const int maxn=200050;
int n,d,a[maxn],b[maxn];
bool cmp(int x,int y) {
	return x>y;
}
int main()
{
	cin>>n>>d;
	For(i,1,n) cin>>a[i];
	For(i,1,n) cin>>b[i];
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+n+1,cmp);
	a[d]+=b[1];
	int j=2,over_taken=0;
	Rep(i,d-1,1)
	{
		while(a[i]+b[j]> a[d]&&j<=n) j++;
		if(j>n||a[i]+b[j]>a[d]) break;
		over_taken++; j++;
	}
	cout<<d-over_taken<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long p[200000],s[200000];
int main()
{
	int  num,n,k,m=0,i,ind,j;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(i=0;i<n;i++)
	{
		cin>>p[i];
	}
	num=s[k]+p[0];
	ind=n-k;
	for(i=k-1;i>=0;i--)
	{
		if(ind>=n-1)
		{
			break;
		}
		for(j=n-1;j>ind;j--)
		{
			if(s[i]+p[j]>num)
			{
				ind=j+2;
				m++;
				break;
			}
		}
		if(j==ind)
		{
			ind++;
			m++;
		}
	}
	cout<<k-m;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
ll score[200005];
map<ll,bool>mp;
int main(){
	ll n,d;
	cin>>n>>d;
	d--;
	if(n==1){
	cout<<1;
		return 0;
	}

    memset(a,0,sizeof a);
    memset(score,0,sizeof score);
    for(int i=0;i<n;i++)cin>>a[i];
    ll cnt=0;
    ll smax=0;
    for(int i=0;i<n;i++){
    	cin>>score[i];
    	if(i==0)smax=score[i];
    	score[i]-=smax;
    	score[i]-=2*score[i];
    	mp[i]=0;
	}
	sort(score,score+n);
	ll j=0;
    for(int i=d-1;i>=0;i--){
    	j=lower_bound(score,score+n,a[i]-a[d])-score;
    	if(!mp[j]&&j<n&&j>0)mp[j]=1,cnt++;
	}
	cout<<d-cnt+1;
	return 0;
}


#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
int k[200001],l[200001];
int main()
{
    int n,m,q=0,ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    cin>>k[i];
    for(int i=1;i<=n;i++)
    cin>>l[i];
    q=l[1]+k[m];
    l[1]=0x7ffffff;
    for(int i=1;i<=n;i++)
    {
    	if(i!=m)
    	{
    		int u=0;
    		for(int j=1;j<=n;j++)
    		if(k[i]+l[j]<=q)
    		{
    			l[j]=0x7ffffff;
    			u=1;
    			break;
			}
			if(u==0)
            for(int j=1;j<=n;j++)
            {
            if(l[j]!=0x7ffffff)
            {
            l[j]=0x7ffffff;
            ans++;
            break;
            }
        }
		}
	}
	cout<<ans+1;
}