using System;
using System.Linq;

namespace testes
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long N = long.Parse(str[0]);
            long K = long.Parse(str[1]);
            str = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            long[] A = new long[N];
            long[] F = new long[N];
            for(long i = 0; i < N; i++)
            {
                A[i] = long.Parse(str[i]);
                F[i] = long.Parse(str2[i]);
            }
            long ans = 0;
            Array.Sort(A);
            Array.Sort(F);
            Array.Reverse(F);

            if (AAABBB(0, N, K, F, A))
            {
                Console.WriteLine(0);
                return;
            }



            long l = 0, r = 1000000000000;

            while(r - l > 1)
            {
                long mid = (l + r) / 2;
                if (!AAABBB(mid,N,K,F,A))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
            }

            Console.WriteLine(r);

           
        }

        static bool AAABBB(long target, long N,long K, long[] F, long[] A)
        {
            long count = 0, need;
            for (long i = 0; i < N; i++)
            {
                need = target / F[i];
                count += Math.Max(0, A[i] - need);
            }
            return count <= K;
        }
        public static long LIS(long[] c)
        {
            // 部分数列和
            long count = 1;
            long N = c.Length;
            long[] array = new long[N];
            array[0] = c[0];

            for (long i = 1; i < N; i++)
            {
                //for (long p = 0; p < N; p++) Console.Write($"{array[p]},");
                // Console.WriteLine("");
                if (array[count - 1] < c[i])
                {
                    array[count] = c[i];
                    count++;
                    continue;
                }
                for (long j = count - 2; j >= 0; j--)
                {
                    if (array[j] < c[i])
                    {
                        array[j + 1] = c[i];
                        break;
                    }
                }
                if(array[0] > c[i])array[0] = c[i];
            }
            return count;
        }
        public static void Rotation(char[] array, long l, long r)
        {          
        }      
    }   
}

/*
long a, b, c;
a = long.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = long.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = long.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
Member = ReadLine().Split(' ').Select(long.Parse).ToArray();

string[] str = Console.ReadLine().Split(' ');
long[] a = new long[N];
for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]);
 */


Measured memory_bytes: 46520