n, m = map(int, raw_input().split())
arr = map(int, raw_input().split())
for x in map(int, raw_input().split()):
	arr.append(x)
arr.sort()
count = 0
for idx in xrange(2 * n):
	if m < arr[idx]:
		break
	m -= arr[idx]
	count += 1
	if count == n:
		break
print count