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.

Difficulty: interview

Starter code:

Solutions:
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)

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)

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)

# PREYANSH RASTOGI
# 2017176


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()

#!/usr/bin/env python3
import sys

def rint():
    return list(map(int, sys.stdin.readline().split()))
#lines = stdin.readlines()

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)



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)

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))


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)





n,d = list(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)
    


# -*- coding: utf-8 -*-
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):]

#    print(my_award)
#    print(enemies)
#    print(diffs)
#    print(awards)
    
    enemy_idx = 0
    award_idx = 0
    overtakes = 0
       
#    print(award_idx)

    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()

import bisect
n,d=list(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=[50,40,30,25,35,20,15]
# print(newscore)
curscore.sort()
# print(curscore)
# print(nextp)
indexmax=bisect.bisect(curscore,newscore)
indexmin=bisect.bisect(curscore,curscore[lenarr-1-d])

largerpoint=0
# print(indexmin,indexmax)
for i in range(indexmin,indexmax):
    # print(curscore[i],end=" ")
    subval=newscore-curscore[i]
    indexsub=bisect.bisect(nextp,subval)-1
    # print(indexsub)
    if indexsub<0:
        largerpoint+=1
        continue
    else:
        nextp.pop(indexsub)

print(len(curscore)-indexmax+largerpoint+1)


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
    else:
        if a[i] + b[j] > score:
            current_pos += 1
        elif a[i] + b[j] <= score:
            j -= 1
    i += 1
print(current_pos)

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)

    


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)

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,p=list(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))			



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())
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)

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)

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)

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())

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,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)

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, 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)