N, K = map(int, input().split())
A = list(map(int, input().split())) # 消化コスト
F = list(map(int, input().split())) # 食べにくさ
 
import math
import numpy as np
 
A.sort(reverse = True)
F.sort()
 
arrA = np.array(A)
arrF = np.array(F)
 
range_max = max(arrA * arrF) + 1
range_min = max(min((A-K) * B), 0)
 
my_lambda = lambda x: sum([max(math.ceil(A[i] - x/F[i]), 0) for i in range(0, N)]) <= K
 
my_range = range(range_min, range_max)
 
def node(lst):
    len_lst = len(lst)
    if len_lst % 2 == 0:
        mid_idx = int(len_lst/2)
    else:
        mid_idx = int(math.floor(len_lst/2))
 
    if len_lst == 1:
        print(lst[mid_idx])
        return()
 
    if my_lambda(lst[mid_idx-1]) == True:
        left = lst[0:mid_idx]
        node(left)
    else:
        right = lst[mid_idx:]
        node(right)
node(my_range)