import sys

import bisect

import itertools

import collections

import fractions

import heapq

import math

from operator import mul

from functools import reduce

from functools import lru_cache





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n, k = list(map(int, input().rstrip('\n').split()))

    a = list(map(int, input().rstrip('\n').split()))

    a.sort()

    f = list(map(int, input().rstrip('\n').split()))

    f.sort(reverse=True)

    cor_v = 10 ** 20

    inc_v = -1

    while cor_v - inc_v > 1:

        bin_v = (cor_v + inc_v) // 2

        cost = 0

        #条件を満たすcostを全検索

        for i in range(n):

            t = a[i] * f[i]

            if t > bin_v:

                cost += (t - bin_v + f[i] - 1) // f[i]

        #costが制約を満たすか

        if cost <= k:

            cor_v = bin_v

        else:

            inc_v = bin_v

    print(cor_v)





if __name__ == '__main__':

    solve()

import sys





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n, k = list(map(int, input().rstrip('\n').split()))

    a = list(map(int, input().rstrip('\n').split()))

    a.sort()

    f = list(map(int, input().rstrip('\n').split()))

    f.sort(reverse=True)

    cor_v = 10 ** 13

    inc_v = -1

    while cor_v - inc_v > 1:

        bin_v = (cor_v + inc_v) // 2

        cost = 0

        #条件を満たすcostを全検索

        for i in range(n):

            t = a[i] * f[i]

            if t > bin_v:

                cost += (t - bin_v + f[i] - 1) // f[i]

        #costが制約を満たすか

        if cost <= k:

            cor_v = bin_v

        else:

            inc_v = bin_v

    print(cor_v)





if __name__ == '__main__':

    solve()

import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n, k = list(map(int, input().rstrip("\n").split()))
    a = list(map(int, input().rstrip("\n").split()))
    a.sort()
    f = list(map(int, input().rstrip("\n").split()))
    f.sort(reverse=True)
    cor_v = 10**20
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        # 条件を満たすcostを全検索
        for i in range(n):
            t = a[i] * f[i]
            if t > bin_v:
                cost += (t - bin_v + f[i] - 1) // f[i]
        # costが制約を満たすか
        if cost <= k:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == "__main__":
    solve()

import sys


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n, k = list(map(int, input().rstrip("\n").split()))
    a = list(map(int, input().rstrip("\n").split()))
    a.sort()
    f = list(map(int, input().rstrip("\n").split()))
    f.sort(reverse=True)
    cor_v = 10**13
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        # 条件を満たすcostを全検索
        for i in range(n):
            t = a[i] * f[i]
            if t > bin_v:
                cost += (t - bin_v + f[i] - 1) // f[i]
        # costが制約を満たすか
        if cost <= k:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == "__main__":
    solve()

-import bisect -import itertools -import collections -import fractions -import heapq -import math -from operator import mul -from functools import reduce -from functools import lru_cache -    cor_v = 10**20 +    cor_v = 10**13