import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    long k;
    readf("%s %s", &n, &k);
    readln;

    auto a = readln.chomp.split.map!(to!int).array;
    auto f = readln.chomp.split.map!(to!int).array;
    
    a.sort();
    f.sort().reverse();
    
    bool isOk(long m, long k) {
        foreach (ae, fe; lockstep(a, f)) {
            if (ae.to!long * fe <= m) { continue; }
            
            int need = ae - (m / fe).to!int;
            k -= need;
        }
        
        return k >= 0;
    }
    
    long le = 0, r = 10L ^^ 12;
    while (le < r) {
        long m = (le + r) / 2;
        
        if (isOk(m, k)) { r = m; }
        else { le = m+1; }
    }
    
    le.writeln;
}