Formula 1 officials decided to introduce new competition. Cars are replaced by space ships and number of points awarded can differ per race.

Given the current ranking in the competition and points distribution for the next race, your task is to calculate the best possible ranking for a given astronaut after the next race. It's guaranteed that given astronaut will have unique number of points before the race.


-----Input-----

The first line contains two integer numbers $N$ ($1 \leq N \leq 200000$) representing number of F1 astronauts, and current position of astronaut $D$ ($1 \leq D \leq N$) you want to calculate best ranking for (no other competitor will have the same number of points before the race).

The second line contains $N$ integer numbers $S_k$ ($0 \leq S_k \leq 10^8$, $k=1...N$), separated by a single space, representing current ranking of astronauts. Points are sorted in non-increasing order.

The third line contains $N$ integer numbers $P_k$ ($0 \leq P_k \leq 10^8$, $k=1...N$), separated by a single space, representing point awards for the next race. Points are sorted in non-increasing order, so winner of the race gets the maximum number of points.


-----Output-----

Output contains one integer number — the best possible ranking for astronaut after the race. If multiple astronauts have the same score after the race, they all share the best ranking.


-----Example-----
Input
4 3
50 30 20 10
15 10 7 3

Output
2



-----Note-----

If the third ranked astronaut wins the race, he will have 35 points. He cannot take the leading position, but he can overtake the second position if the second ranked astronaut finishes the race at the last position.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms


Solutions:
(n, k) = map(int, input().strip().split())
cr = list(map(int, input().strip().split()))
pa = list(map(int, input().strip().split()))
x = cr[k - 1] + pa[0]
p = 0
if k == 1:
	print(1)
else:
	for i in range(k - 1):
		if cr[i] + pa[-1] <= x:
			p += 1
			del pa[-1]
	print(k - p)


import sys
input = sys.stdin.readline
(n, d) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
score = a[d - 1] + b[0]
current_pos = 1
j = n - 1
k = 1
i = 0
while i != d - 1:
	if a[i] > score:
		current_pos += 1
		k += 1
	elif a[i] + b[j] > score:
		current_pos += 1
	elif a[i] + b[j] <= score:
		j -= 1
	i += 1
print(current_pos)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ps = []
cs = a[d - 1] + b[0]
b = b[1:]
f = 0
a.pop(d - 1)
src = []
j = n - 2
i = 0
for k in range(n - 1):
	if a[k] > cs:
		src.append(a[k] + b[i])
		i += 1
	else:
		src.append(a[k] + b[j])
		j -= 1
src.sort(reverse=True)
for j in range(n - 1):
	if cs >= src[j]:
		print(j + 1)
		f = 1
		break
if f == 0:
	print(n)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 6 + 7
(n, d) = R()
s = L()
p = L()
pnt = s[d - 1] + p[0]
pos = 0
for i in range(d - 1):
	if s[i] + p[-1] <= pnt:
		pos += 1
		del p[-1]
print(d - pos)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
new = list(map(int, input().split()))
number = l[b - 1] + new[0]
for i in range(b - 1):
	if number >= new[-1] + l[i]:
		b -= 1
		del new[-1]
print(b)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, d) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a[d - 1] += b[0]
	b = b[1:]
	low = 0
	high = n - 2
	for x in range(n):
		if x != d - 1:
			if a[x] > a[d - 1]:
				a[x] += b[low]
				low += 1
			else:
				a[x] += b[high]
				high -= 1
	rank = []
	for x in range(n):
		rank.append([a[x], x + 1])
	rank.sort(reverse=True)
	prev = -1
	cnt = 0
	for x in range(n):
		if rank[x][0] != prev:
			cnt += 1
		if rank[x][1] == d:
			break
	print(cnt)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys

def rint():
	return list(map(int, sys.stdin.readline().split()))
(N, D) = rint()
S = list(rint())
P = list(rint())
new_score = S[D - 1] + P[0]
k = 1
ans = 0
for i in range(D - 2, -1, -1):
	if k > N - 1:
		ans = i + 2
		break
	for j in range(k, N):
		if S[i] + P[j] <= new_score:
			k = j + 1
			break
	else:
		ans = i + 2
		break
else:
	ans = 1
print(ans)


import sys
from sys import stdin, stdout
(n, d) = map(int, stdin.readline().split(' '))
ini = list(map(int, stdin.readline().split(' ')))
poi = list(map(int, stdin.readline().split(' ')))
maxp = ini[d - 1] + poi[0]
ctr3 = 0
for i in range(d - 1):
	if ini[i] + poi[-1] <= maxp:
		ctr3 += 1
		poi.pop(-1)
print(d - ctr3)


import bisect
(n, d) = map(int, input().strip().split())
d = d - 1
curscore = list(map(int, input().strip().split()))
nextp = list(map(int, input().strip().split()))
lenarr = len(curscore)
newscore = curscore[d] + nextp.pop(0)
nextp.sort()
curscore.sort()
indexmax = bisect.bisect(curscore, newscore)
indexmin = bisect.bisect(curscore, curscore[lenarr - 1 - d])
largerpoint = 0
for i in range(indexmin, indexmax):
	subval = newscore - curscore[i]
	indexsub = bisect.bisect(nextp, subval) - 1
	if indexsub < 0:
		largerpoint += 1
		continue
	else:
		nextp.pop(indexsub)
print(len(curscore) - indexmax + largerpoint + 1)


(n, d) = list(map(int, input().split()))
sk = list(map(int, input().split()))
pk = list(map(int, input().split()))
sk[d - 1] += pk[0]
pk.pop(0)
rank = 1
for i in range(d - 1):
	if sk[i] + pk[-1] > sk[d - 1]:
		rank += 1
	elif sk[i] + pk[-1] == sk[d - 1]:
		pk.pop()
	else:
		j = len(pk) - 1
		pk.pop(j)
print(rank)


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))

def printDivisors(n):
	divisors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				divisors.append(i)
			else:
				divisors.extend((i, n // i))
		i = i + 1
	return divisors

def countTotalBits(num):
	binary = bin(num)[2:]
	return len(binary)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
(n, d) = vary(2)
intial = array_int()
winnig = array_int()
intial[d - 1] = intial[d - 1] + winnig[0]
j = n - 1
count = 0
for i in range(d - 1):
	if intial[i] + winnig[j] <= intial[d - 1]:
		count += 1
		j -= 1
print(d - count)


(n, d) = map(int, input().split())
pos = list(map(int, input().split()))
points = list(map(int, input().split()))
cur = d - 1
cur_score = pos[cur] + points[0]
q = n - 1
for i in range(cur):
	if pos[i] + points[q] <= cur_score:
		q -= 1
		cur -= 1
print(cur + 1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
points = list(map(int, input().split()))
indexl = k - 2
indexpoint = 1
val = l[k - 1] + points[0]
while True:
	if indexpoint == n or indexl == -1:
		break
	if points[indexpoint] + l[indexl] > val:
		indexpoint += 1
	else:
		indexpoint += 1
		indexl -= 1
print(indexl + 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k -= 1
ans = b[0] + a[k]
rem = k - 1
res = 1
for i in range(n - k, n):
	if b[i] + a[rem] > ans:
		res += 1
	else:
		rem -= 1
print(res)


a = input().split()
a = [int(i) for i in a]
b = input().split()
b = [int(i) for i in b]
c = input().split()
c = [int(i) for i in c]
cha = []
for i in range(0, a[1] - 1):
	cha.append(b[i] - b[a[1] - 1])
cao = []
for i in range(1, a[1]):
	cao.append(c[0] - c[-i])
dui = 0
cha.sort()
cao.sort()
i = 0
j = 0
while j < a[1] - 1:
	if cha[i] <= cao[j]:
		dui += 1
		i += 1
		j += 1
	else:
		j += 1
print(a[1] - dui)


(n, d) = map(int, input().split())
s = list(map(int, input().split()))
p = list(map(int, input().split()))
maxPoints = s[d - 1] + p[0]
pos = n - 1
points = 1
count = 0
while pos >= 0 and points < n:
	if pos == d - 1:
		pos -= 1
	elif s[pos] + p[points] <= maxPoints:
		count += 1
		points += 1
		pos -= 1
	else:
		points += 1
print(n - count)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import *
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, p) = tup()
a = lint()
b = lint()
x = a[p - 1] + b[0]
for i in range(p - 1):
	if a[i] + b[-1] <= x:
		b.pop()
		p -= 1
print(p)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


(n, d) = list(map(int, input().split()))
sk = list(map(int, input().split()))
pk = list(map(int, input().split()))
sk[d - 1] += pk[0]
rank = 1
for i in range(d - 1):
	if sk[i] + pk[-1] > sk[d - 1]:
		rank += 1
	else:
		del pk[-1]
print(rank)


(n, k) = map(int, input().strip().split(' '))
lstc = list(map(int, input().strip().split(' ')))
lstf = list(map(int, input().strip().split(' ')))
ind = k - 1
p = lstc[ind] + lstf[0]
r = 1
ifr = 1
ib = n - 1
j = 0
while j < ind:
	if lstc[j] + lstf[ib] > p:
		r += 1
		ifr += 1
	else:
		ib -= 1
	j += 1
print(r)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k -= 1
ans = b[0] + a[k]
rem = k - 1
res = 1
for i in range(n - k, n):
	if b[i] + a[rem] > ans:
		res += 1
	else:
		rem -= 1
print(res)


(n, d) = [int(x) for x in input().split()]
sk = [int(x) for x in input().split()]
pk = [int(x) for x in input().split()]
maxm = sk[d - 1] + max(pk)
dip = 0
pkk = 1
for k in range(0, d):
	if sk[k] + pk[-pkk] <= maxm:
		dip += 1
		pkk += 1
print(d - dip + 1)


from bisect import bisect_right
(num_racers, selected_racer) = list(map(int, input().split()))
selected_racer -= 1
racers_points = list(map(int, input().split()))
selected_racer_points = racers_points[selected_racer]
awards = list(map(int, input().split()))
awards.sort(reverse=True)
selected_racer_points += awards[0]
remaining_awards = awards[1:]
del racers_points[selected_racer]
remaining_racers_points = sorted(racers_points, reverse=True)
best_award_pos = 0
worst_award_pos = len(remaining_awards) - 1
for (pos, racer_points) in enumerate(remaining_racers_points):
	if racer_points + remaining_awards[worst_award_pos] <= selected_racer_points:
		remaining_racers_points[pos] += remaining_awards[worst_award_pos]
		worst_award_pos -= 1
	else:
		remaining_racers_points[pos] += remaining_awards[best_award_pos]
		best_award_pos += 1
remaining_racers_points.append(selected_racer_points)
remaining_racers_points.sort()
print(num_racers + 1 - bisect_right(remaining_racers_points, selected_racer_points))


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
(n, d) = get_ints()
s = list(map(int, input().split()))
p = list(map(int, input().split()))
m = s.pop(d - 1)
a = p.pop(0) + m
p.reverse()
j = 0
ans = -1
for i in range(n - 1):
	if s[i] + p[j] > a:
		z = p.pop(-1)
		s[i] += z
	else:
		s[i] += p[j]
		j += 1
s.append(a)
s.sort()
s.reverse()
print(s.index(a) + 1)


I = lambda : map(int, input().split())
(n, d) = I()
(r, p) = (list(I()), list(I()))
(q, w, e, t) = (r[d - 1] + p[0], d - 2, 1, 0)
while w >= 0 and e < n:
	if r[w] + p[e] <= q:
		w -= 1
		t += 1
	e += 1
print(d - t)


(n, d) = [int(x) for x in input().split()]
s = list(map(int, input().split()))
l = list(map(int, input().split()))
score = s[d - 1] + l[0]
rank = d
j = n - 1
for i in range(d - 1):
	if s[i] <= score:
		if s[i] + l[j] <= score:
			rank -= 1
			j -= 1
print(rank)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = k
j = n - 1
love = a[k - 1] + b[0]
for i in range(k - 1):
	if love >= a[i] + b[j]:
		x -= 1
		j -= 1
print(x)


(n, d) = map(int, input().strip().split())
pre = list(map(int, input().strip().split()))
nxt = list(map(int, input().strip().split()))
pre[d - 1] += nxt[0]
nxt[0] = -10
k = n
l = 1
ans = 0
for i in range(d - 2, -1, -1):
	for j in range(l, k):
		l += 1
		if pre[i] + nxt[j] <= pre[d - 1]:
			ans += 1
			break
	if l == n:
		break
print(d - ans)


(n, p) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = a[p - 1] + b[0]
cou = 0
for i in range(p - 1):
	if a[i] + b[-1] <= r:
		cou += 1
		del b[-1]
print(p - cou)


(n, d) = map(int, input().split())
d -= 1
(s, p, j) = ([*map(int, input().split())], [*map(int, input().split())], -1)
for i in range(n):
	if s[d] + p[0] < s[i]:
		continue
	if i == d:
		s[i] += p[0]
		break
	else:
		s[i] += p[j]
		j -= 1
print(sorted(s, reverse=True).index(s[d]) + 1)


def __starting_point():
	(n, d) = [int(x) for x in input().split()]
	d -= 1
	s = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	val = p[0] + s[d]
	ans = 1
	t = n - (n - d) - 1
	for i in range(n - d, len(p)):
		if p[i] + s[t] > val:
			ans += 1
		else:
			t -= 1
	print(ans)
__starting_point()


(N, D) = map(int, input().split())
ranking = list(map(int, input().split()))
scores = list(map(int, input().split()))
Ds = ranking[D - 1] + scores[0]
ranking.sort()
import bisect
new = bisect.bisect_right(ranking, Ds, 0, N)
daiding = ranking[N + 1 - D:new]
m = 0
for i in daiding[::-1]:
	if i + scores[-1] <= Ds:
		del scores[-1]
		m += 1
print(D - m)


(n, k) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
p = arr1[k - 1] + arr2[0]
j_f = 1
j_b = n - 1
ans = 0
for i in range(n):
	if i != k - 1:
		if p >= arr1[i] + arr2[j_b]:
			j_b -= 1
			ans += 1
		else:
			j_f += 1
print(n - ans)


import sys
input = sys.stdin.buffer.readline
(n, d) = map(int, input().split())
d -= 1
s = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
astronaut = s[d] + p[-1]
ptr = n - 2
decreased = 0
for i in range(d - 1, -1, -1):
	while ptr >= 0 and p[ptr] + s[i] > astronaut:
		ptr -= 1
	if ptr < 0:
		break
	else:
		ptr -= 1
		decreased += 1
print(d - decreased + 1)


m = input().split()
n = int(m[0])
j = int(m[1])
l1 = input().split()
l2 = input().split()
p = int(l1[j - 1]) + int(l2[0])
c = j
for i in range(j - 1):
	if p >= int(l1[i]) + int(l2[-1]):
		c -= 1
		l2.pop()
print(c)


(n, d) = map(int, input().split())
s = [*map(int, input().split())]
p = [*map(int, input().split())]
p = p[::-1]
item = s[d - 1] + p[-1]
p.pop()
res = 1
from bisect import bisect as bis
for (i, x) in enumerate(s):
	if i != d - 1:
		diff = item - x
		if diff < 0:
			res += 1
			p.pop()
		else:
			a = bis(p, diff)
			if a == 0:
				p.pop()
				res += 1
			else:
				p.pop(a - 1)
print(res)


import sys
(n, d) = map(int, sys.stdin.readline().split())
curr_scores = list(map(int, sys.stdin.readline().split()))
win_scores = list(map(int, sys.stdin.readline().split()))
max_possible = curr_scores[d - 1] + win_scores[0]
ans = 0
j = n - 1
for i in range(d):
	if curr_scores[i] > max_possible:
		ans += 1
	elif curr_scores[i] == max_possible:
		if win_scores[j] == 0:
			j -= 1
		else:
			ans += 1
	elif win_scores[j] + curr_scores[i] > max_possible:
		ans += 1
	else:
		j -= 1
print(ans + 1)


(n, d) = map(int, input().split())
s = list(map(int, input().split()))
p = list(map(int, input().split()))
d -= 1
maxHis = s[d] + p[0]
i = n - 1
j = 1
count = 0
while j < n:
	if i == d:
		i -= 1
	else:
		while j < n and s[i] + p[j] > maxHis:
			j += 1
		if j == n:
			break
		else:
			j += 1
			count += 1
			i -= 1
print(n - count)


(n, d) = map(int, input().split())
s = [int(x) for x in input().split()]
p = [int(X) for X in input().split()]
z = []
tt = s[d - 1] + p[0]
z.append(s[d - 1] + p[0])
p[0] = -1
s[d - 1] = -1
i = 0
j = 1
v = n - 1
s.sort(reverse=True)
p.sort()
while i < n - 1 and j <= v:
	if s[i] + p[j] <= tt:
		z.append(s[i] + p[j])
		i += 1
		j += 1
	else:
		z.append(s[i] + p[v])
		i += 1
		v -= 1
z.sort(reverse=True)
print(z.index(tt) + 1)


def RA():
	return list(map(int, input().split()))

def solve():
	(n, my_rank) = RA()
	cur_scores = RA()
	next_scores = RA()
	my_score = cur_scores[my_rank - 1] + next_scores[0]
	better_than_me = 0
	j = n - 1
	for i in range(n):
		if i == my_rank - 1:
			continue
		if cur_scores[i] + next_scores[j] > my_score:
			better_than_me += 1
		else:
			j -= 1
	print(better_than_me + 1)
solve()


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
imp = i = 0
while a[i] > a[k - 1] + b[0]:
	imp += 1
	i += 1
key = a[k - 1] + b[0]
a[k - 1] += b[0]
for j in range(i):
	a[j] += b[j + 1]
a = sorted(a, reverse=True)
ind = a.index(key)
q = imp + 1
for k in range(n - 1, ind, -1):
	a[k] += b[q]
	q += 1
a = sorted(a, reverse=True)
print(a.index(key) + 1)


(n, p) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = a[p - 1] + b[0]
z = p - 2
c = 0
for i in range(1, n):
	if b[i] + a[z] <= x:
		c += 1
		z -= 1
	if z < 0:
		break
print(max(p - c, 1))


(n, d) = (int(i) for i in input().split())
l1 = [int(i) for i in input().split()]
l2 = [int(i) for i in input().split()]
l1[d - 1] += l2[0]
k = l1[d - 1]
k1 = d - 1
for i in range(n):
	if l1[i] <= k:
		l1.remove(k)
		l1.insert(i, k)
		k1 = i
		break
for i in range(n):
	if i < k1:
		l1[i] += l2[i + 1]
	if i > k1:
		l1[i] += l2[n + k1 - i]
		if l1[i] > k:
			k1 += 1
print(k1 + 1)


from math import ceil

def problem(line1, line2, line3):
	in1 = list(map(int, line1.split()))
	n = in1[0]
	position = in1[1]
	standings = list(map(int, line2.split()))
	awards = list(map(int, line3.split()))
	if n == 1 or position == 1:
		return 1
	my_points = standings[position - 1]
	my_award = awards[0]
	diffs = []
	for (index, p) in enumerate(reversed(standings[0:position - 1])):
		diffs.append(p - my_points)
	enemies = position - 1
	awards = awards[-enemies:]
	enemy_idx = 0
	award_idx = 0
	overtakes = 0
	while award_idx < len(awards):
		while award_idx < enemies and diffs[enemy_idx] + awards[award_idx] > my_award:
			award_idx += 1
		if award_idx < enemies and diffs[enemy_idx] + awards[award_idx] <= my_award:
			overtakes += 1
			enemy_idx += 1
			award_idx += 1
		else:
			break
	return position - overtakes

def __starting_point():
	line1 = input()
	line2 = input()
	line3 = input()
	result = problem(line1, line2, line3)
	print(result)
__starting_point()


from bisect import bisect_right
(n, d) = map(int, input().split())
s = list(map(int, input().split()))
p = list(map(int, input().split()))
t_wyn = []
wyn = s[d - 1] + p[0]
t_wyn.append(wyn)
del s[d - 1]
s_sort = sorted(s)
p_sort = sorted(p)
p_sort.pop()
for x in range(0, len(s), +1):
	szuk = wyn - s_sort[x] - 1
	if szuk < 0:
		t_wyn.append(s_sort[x] + p_sort[-1])
	else:
		pos = bisect_right(p_sort, szuk)
		if pos > 0:
			t_wyn.append(s_sort[x] + p_sort[pos - 1])
			del p_sort[pos - 1]
			continue
		else:
			t_wyn.append(s_sort[x] + p_sort[-1])
	p_sort.pop()
t_wyn = sorted(t_wyn)
pos = bisect_right(t_wyn, wyn)
print(n - (pos - 1))


(n, d) = map(int, input().split())
s = list(map(int, input().split()))
k = list(map(int, input().split()))
x = s[d - 1] + k[0]
j = 0
o = 0
for i in range(d - 2, -1, -1):
	j += 1
	while j < len(k) and s[i] + k[j] > x:
		j += 1
	if j >= len(k):
		o = i + 1
		break
print(o + 1)


from collections import deque
(n, who) = map(int, input().split())
who -= 1
rating = list(map(int, input().split()))
score = deque(map(int, input().split()))
rating[who] += score.popleft()
bestWho = rating[who]
for i in range(n):
	if i == who:
		continue
	if rating[i] + score[-1] > bestWho:
		rating[i] += score.popleft()
	else:
		rating[i] += score.pop()
print(sorted(rating, reverse=True).index(bestWho) + 1)


(n, d) = [int(i) for i in input().split()]
atual = [int(i) for i in input().split()]
prox = [int(i) for i in input().split()]
atual[d - 1] += prox[0]
prox[0] = -1
(k, aux) = (n, 1)
ans = 0
for i in range(d - 2, -1, -1):
	for j in range(aux, k):
		aux += 1
		if atual[i] + prox[j] <= atual[d - 1]:
			ans += 1
			break
	if aux == n:
		break
print(d - ans)


import sys
input = sys.stdin.readline

def solve(n, d, cur, race):
	if d == 0:
		return 1
	pts = cur[d] + race[0]
	comp_index = d - 1
	point_index = 1
	while comp_index != -1:
		comp_pts = cur[comp_index]
		while point_index < n and comp_pts + race[point_index] > pts:
			point_index += 1
		if point_index == n:
			return comp_index + 2
		else:
			point_index += 1
		comp_index -= 1
	return 1
(n, d) = map(int, input().split())
d -= 1
cur = list(map(int, input().split()))
race = list(map(int, input().split()))
print(solve(n, d, cur, race))


I = lambda : map(int, input().split())
(n, p) = I()
a = list(I())
b = list(I())
r = a[p - 1] + b[0]
s = 0
for i in range(p - 1):
	if r >= b[-1] + a[i]:
		s += 1
		del b[-1]
print(p - s)


for _ in range(1):
	(n, k) = map(int, input().split())
	cr = list(map(int, input().split()))
	pt = list(map(int, input().split()))
	mx = max(pt) + cr[k - 1]
	c = 0
	for i in range(k - 1):
		if cr[i] + pt[-1] <= mx:
			c += 1
			del pt[-1]
	print(k - c)