#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/less.hpp
#ifndef LESS_HPP
#define LESS_HPP


/*
usage:

std::sort(a.begin(), a.end(), tools::less<int, int>([](int a_i) { return std::abs(x); }));
*/

namespace tools {
  template <class T, class R>
  ::std::function<bool(T, T)> less(const ::std::function<R(T)>& selector) {
    return [selector](const T& x, const T& y) {
      return selector(x) < selector(y);
    };
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> A, F;
  tools::read(A, N);
  tools::read(F, N);

  std::sort(A.begin(), A.end());
  std::sort(F.begin(), F.end(), std::greater<i64>());
  std::vector<std::pair<i64, i64>> pairs;
  for (i64 i = 0; i < N; ++i) {
    pairs.push_back(std::make_pair(A[i] * F[i], F[i]));
  }

  const auto f = [&pairs](const i64& x) {
    i64 y = 0;
    for (const auto& pair : pairs) {
      y += tools::ceil<i64>(std::max<i64>(0, pair.first - x), pair.second);
    }
    return y;
  };

  if (f(0) <= K) {
    std::cout << 0 << std::endl;
    return 0;
  }

  i64 ng = 0;
  i64 ok = std::max_element(pairs.begin(), pairs.end(), tools::less<std::pair<i64, i64>, i64>([](const std::pair<i64, i64>& pair) { return pair.first; }))->first;
  while (ok - ng > 1) {
    const i64 center = (ng + ok) / 2;
    if (f(center) <= K) {
      ok = center;
    } else {
      ng = center;
    }
  }

  std::cout << ok << std::endl;
  return 0;
}

Measured memory_bytes: 9456