import sys

input = sys.stdin.readline

N, K = list(map(int, input().split()))

a = list(map(int, input().split()))

f = list(map(int, input().split()))

a.sort()

f.sort(reverse = True)

res = 0

l = 0

r = 10 ** 12

m = int((l + r) / 2)

c = 0

if sum(a) <= K:

  print((0))

  exit(0)

def check(x):

  k = K + 0

  for i in range(N):

    if a[i] * f[i] > x:

      k -= abs((x - a[i] * f[i]) // f[i])

    if k < 0:

      return False

  return True

while c <= 64:

  m = int((l + r) / 2)

  if check(m) == True:

    r = m

  else:

    l = m

  c += 1

if check(m + 1): print((m + 1))

elif check(max(0, m - 1)): print((m - 1))

else: print(m)
import sys

input = sys.stdin.readline

N, K = list(map(int, input().split()))

a = list(map(int, input().split()))

b = list(map(int, input().split()))

a.sort()

b.sort(reverse = True)



def check(x):

  k = K

  for i in range(N):

    if a[i] * b[i] > x: k += (x - a[i] * b[i]) // b[i]

  return k >= 0



ok = 10 ** 12

ng = -1

while ok - ng > 1:

  m = (ok + ng) // 2

  if check(m): ok = m

  else: ng = m

print(ok)
import sys

input = sys.stdin.readline
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
res = 0
l = 0
r = 10**12
m = int((l + r) / 2)
c = 0
if sum(a) <= K:
    print((0))
    exit(0)


def check(x):
    k = K + 0
    for i in range(N):
        if a[i] * f[i] > x:
            k -= abs((x - a[i] * f[i]) // f[i])
        if k < 0:
            return False
    return True


while c <= 64:
    m = int((l + r) / 2)
    if check(m) == True:
        r = m
    else:
        l = m
    c += 1
if check(m + 1):
    print((m + 1))
elif check(max(0, m - 1)):
    print((m - 1))
else:
    print(m)

import sys

input = sys.stdin.readline
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)


def check(x):
    k = K
    for i in range(N):
        if a[i] * b[i] > x:
            k += (x - a[i] * b[i]) // b[i]
    return k >= 0


ok = 10**12
ng = -1
while ok - ng > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m
print(ok)

-f = list(map(int, input().split())) +b = list(map(int, input().split())) -f.sort(reverse=True) -res = 0 -l = 0 -r = 10**12 -m = int((l + r) / 2) -c = 0 -if sum(a) <= K: -    print((0)) -    exit(0) +b.sort(reverse=True) -    k = K + 0 +    k = K -        if a[i] * f[i] > x: -            k -= abs((x - a[i] * f[i]) // f[i]) -        if k < 0: -            return False -    return True +        if a[i] * b[i] > x: +            k += (x - a[i] * b[i]) // b[i] +    return k >= 0 -while c <= 64: -    m = int((l + r) / 2) -    if check(m) == True: -        r = m +ok = 10**12 +ng = -1 +while ok - ng > 1: +    m = (ok + ng) // 2 +    if check(m): +        ok = m -        l = m -    c += 1 -if check(m + 1): -    print((m + 1)) -elif check(max(0, m - 1)): -    print((m - 1)) -else: -    print(m) +        ng = m +print(ok)