#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(dead_code)]
pub trait BinarySearch<T> {
    /// the first element which does not compare less than val
    fn lower_bound(&self, x: &T) -> usize;
    /// the first element which compares grater than val
    fn upper_bound(&self, x: &T) -> usize;
}
#[allow(dead_code)]
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i32;
        while ok - ng > 1 {
            let mid = (ng + ok) / 2;
            if self[mid as usize] >= *x {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok as usize
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i32;
        while ok - ng > 1 {
            let mid = (ng + ok) / 2;
            if self[mid as usize] > *x {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok as usize
    }
}

use std::fmt::Debug;
use std::ops::{Add, Sub, Div};

#[allow(dead_code)]
/// loop invariant: pred(l) = false, pred(r) = true
fn binary_search<T>(l: T, r: T, pred: impl Fn(T) -> bool) -> T
where T: Copy + Add<Output=T> + Sub<Output=T> + Div<Output=T> + From<u8> + PartialOrd + Debug
{
    let mut ng = l;
    let mut ok = r;
    while ok - ng > T::from(1_u8) {
        let mid = (ng + ok) / T::from(2_u8);
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok
}

fn main() {
    input! {
        n: usize,
        k: i64,
        a_: [i64; n],
        f_: [i64; n],
    }
    let mut a = a_.clone();
    a.sort();
    let mut food = f_.clone();
    food.sort();

    let pred = |c| {
        let mut r: Vec<i64> = (0..n).map(|i| c / food[i]).collect();
        r.sort();
        let cnt: i64 = (0..n).map(|i| (a[i] - r[i]).max(0)).sum();
        cnt <= k
    };
    let ret = binary_search(-1, 1e13 as i64, pred);
    println!("{}", ret);
}
// A: 3 1 4 1 5 9 2 6 5 3 5
// A: 1 1 2 3 3 4 5 5 5 6 9

// F: 8 9 7 9 3 2 3 8 4 6 2
//    1 1 1 1 4 6 4 1 3 2 6
//    1 1 1 1 1 2 3 4 4 6 6
// A: 1 1 2 3 3 4 5 5 5 6 9
//        1 2 2 2 2 1 1   3


Measured memory_bytes: 10636