//このコードは自分で考えたものではなく、借用しています


using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split();
        int N = int.Parse(str[0]);
        long K = long.Parse(str[1]);
        long[] A = new long[N];
        long[] B = new long[N];
        string[] str2 = Console.ReadLine().Split();
        string[] str3 = Console.ReadLine().Split();
        for (var i = 0; i < N; i++)
        {
            A[i] = long.Parse(str2[i]);
            B[i] = long.Parse(str3[i]);
        }
        Array.Sort(A);
        Array.Sort(B);
        Array.Reverse(B);
        long min = 0;
        long max = long.MaxValue;
        while (min < max)
        {
            long m = (min + max) / 2;
            long s = 0;
            for (var i = 0; i < N; i++)
            {
                long t = m / B[i];
                if (A[i] > t)
                {
                    s += A[i] - t;
                }
            }
            if (s > K)
            {
                min = m + 1;
            }
            else
            {
                max = m;
            }
        }
        Console.WriteLine(min);
    }
}
