n,m = [int(i) for i in raw_input().split()]
a = [int(i) for i in raw_input().split()]
c = [int(i) for i in raw_input().split()]
arr = a+c
arr.sort()
s=0
cnt=-1
for ele in arr:
	s+=ele
	cnt+=1
	if s>m:
		break
print min(cnt,n)