import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np



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

A = np.array(readline().split(),np.int64)

F = np.array(readline().split(),np.int64)



A.sort(); F.sort(); F=F[::-1]



def test(x):

    # 全員がx秒以下に収めるための必要コストがK以下である

    return np.maximum(0,A-x//F).sum() <= K



left = -1 # 不可能目標

right = 10**13 # 可能目標

while left+1 < right:

    mid = (left+right)//2

    if test(mid):

        right = mid

    else:

        left = mid



answer = right

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np



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

A = np.array(readline().split(),np.int64)

F = np.array(readline().split(),np.int64)



A.sort(); F.sort(); F=F[::-1]



Asum = A.sum()



def test(x):

    # 全員がx秒以下に収めるための必要コストがK以下である

    return Asum - np.minimum(A,x//F).sum() <= K



left = -1 # 不可能目標

right = 10**13 # 可能目標

while left+1 < right:

    mid = (left+right)//2

    if test(mid):

        right = mid

    else:

        left = mid



answer = right

print(answer)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N, K = list(map(int, readline().split()))
A = np.array(readline().split(), np.int64)
F = np.array(readline().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]


def test(x):
    # 全員がx秒以下に収めるための必要コストがK以下である
    return np.maximum(0, A - x // F).sum() <= K


left = -1  # 不可能目標
right = 10**13  # 可能目標
while left + 1 < right:
    mid = (left + right) // 2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N, K = list(map(int, readline().split()))
A = np.array(readline().split(), np.int64)
F = np.array(readline().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]
Asum = A.sum()


def test(x):
    # 全員がx秒以下に収めるための必要コストがK以下である
    return Asum - np.minimum(A, x // F).sum() <= K


left = -1  # 不可能目標
right = 10**13  # 可能目標
while left + 1 < right:
    mid = (left + right) // 2
    if test(mid):
        right = mid
    else:
        left = mid
answer = right
print(answer)

+Asum = A.sum() -    return np.maximum(0, A - x // F).sum() <= K +    return Asum - np.minimum(A, x // F).sum() <= K