#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int N;
  cin >> N;
  unsigned long long int K;
  cin >> K;
  vector<long long int> A(N), F(N);
  for (auto &a : A) cin >> a;
  for (auto &f : F) cin >> f;
  sort(A.rbegin(), A.rend());
  sort(F.begin(), F.end());
  long long int high = A[0] * F.back(), low = -1;
  while (high - low > 1) {
    long long int required = 0;
    long long int mid = (high + low) / 2;
    for (int i = 0; i < N; ++i) {
      required += max(0LL, A[i] - (mid / F[i]));
    }
    if (required <= K)
      high = mid;
    else
      low = mid;
  }
  cout << high << '\n';
  return 0;
}
