from numpy import array, int64, minimum



def main():

    N, K, *I = list(map(int, open(0).read().split()))



    A, F = array(I[:N], int64), array(I[N:], int64)

    A.sort()

    F.sort()

    F = F[::-1]



    sum_A = A.sum()



    ng, ok = -1, 10 ** 12

    while ng + 1 < ok:

        mid = (ok + ng) // 2

        if (sum_A - minimum(A, mid // F).sum()) <= K:

            ok = mid

        else:

            ng = mid



    print(ok)





if __name__ == '__main__':

    main()

from numpy import array, int64, minimum

from sys import stdin



def main():

    input = stdin.buffer.readline



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



    A, F = array(input().split(), int64), array(input().split(), int64)

    A.sort()

    F.sort()

    F = F[::-1]



    sum_A = A.sum()



    ng, ok = -1, 10 ** 12

    while ng + 1 < ok:

        mid = (ok + ng) // 2

        if (sum_A - minimum(A, mid // F).sum()) <= K:

            ok = mid

        else:

            ng = mid



    print(ok)





if __name__ == '__main__':

    main()

from numpy import array, int64, minimum


def main():
    N, K, *I = list(map(int, open(0).read().split()))
    A, F = array(I[:N], int64), array(I[N:], int64)
    A.sort()
    F.sort()
    F = F[::-1]
    sum_A = A.sum()
    ng, ok = -1, 10**12
    while ng + 1 < ok:
        mid = (ok + ng) // 2
        if (sum_A - minimum(A, mid // F).sum()) <= K:
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == "__main__":
    main()

from numpy import array, int64, minimum
from sys import stdin


def main():
    input = stdin.buffer.readline
    N, K = list(map(int, input().split()))
    A, F = array(input().split(), int64), array(input().split(), int64)
    A.sort()
    F.sort()
    F = F[::-1]
    sum_A = A.sum()
    ng, ok = -1, 10**12
    while ng + 1 < ok:
        mid = (ok + ng) // 2
        if (sum_A - minimum(A, mid // F).sum()) <= K:
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == "__main__":
    main()

+from sys import stdin -    N, K, *I = list(map(int, open(0).read().split())) -    A, F = array(I[:N], int64), array(I[N:], int64) +    input = stdin.buffer.readline +    N, K = list(map(int, input().split())) +    A, F = array(input().split(), int64), array(input().split(), int64)