import sys

input = sys.stdin.buffer.readline

import numpy as np



def main():

    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)



    if sum(a) <= K:

        print((0))

    else:

        a = np.array(a)

        f = np.array(f)

        left,right = 0,max(a)*max(f)

        while right-left > 1:

            mid = (left+right)//2

            pra = a-mid//f

            pra[pra<0] = 0

            if np.sum(pra) > K:

                left = mid

            else:

                right = mid

        print(right)



if __name__ == "__main__":

    main()

import sys

input = sys.stdin.buffer.readline



def main():

    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)

    

    l,r = -1,max(a)*max(f)+1

    

    while r-l>1:

        mid = (r+l)//2

        count = 0

        for cost,dif in zip(a,f):

            if mid >= cost*dif:

                continue

            rest = cost*dif-mid

            count += -(-rest//dif)

        if count <= K:

            r = mid

        else:

            l = mid

            

    print(r)



if __name__ == "__main__":

    main()

import sys

input = sys.stdin.buffer.readline
import numpy as np


def main():
    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)
    if sum(a) <= K:
        print((0))
    else:
        a = np.array(a)
        f = np.array(f)
        left, right = 0, max(a) * max(f)
        while right - left > 1:
            mid = (left + right) // 2
            pra = a - mid // f
            pra[pra < 0] = 0
            if np.sum(pra) > K:
                left = mid
            else:
                right = mid
        print(right)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.buffer.readline


def main():
    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)
    l, r = -1, max(a) * max(f) + 1
    while r - l > 1:
        mid = (r + l) // 2
        count = 0
        for cost, dif in zip(a, f):
            if mid >= cost * dif:
                continue
            rest = cost * dif - mid
            count += -(-rest // dif)
        if count <= K:
            r = mid
        else:
            l = mid
    print(r)


if __name__ == "__main__":
    main()

-import numpy as np -    if sum(a) <= K: -        print((0)) -    else: -        a = np.array(a) -        f = np.array(f) -        left, right = 0, max(a) * max(f) -        while right - left > 1: -            mid = (left + right) // 2 -            pra = a - mid // f -            pra[pra < 0] = 0 -            if np.sum(pra) > K: -                left = mid -            else: -                right = mid -        print(right) +    l, r = -1, max(a) * max(f) + 1 +    while r - l > 1: +        mid = (r + l) // 2 +        count = 0 +        for cost, dif in zip(a, f): +            if mid >= cost * dif: +                continue +            rest = cost * dif - mid +            count += -(-rest // dif) +        if count <= K: +            r = mid +        else: +            l = mid +    print(r)