#include <bits/stdc++.h>
using namespace std;
vector<int> cc, df;
int n;
long long k;
int check(int val) {
  long long c = k;
  for (int i = 0; i < n; i++) {
    int t = min<int long long>(cc[i], val / df[i]);
    c -= cc[i] - t;
    if (c < 0) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> k;
  int t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    cc.push_back(t);
  }
  for (int i = 0; i < n; i++) {
    cin >> t;
    df.push_back(t);
  }
  sort(cc.begin(), cc.end());
  sort(df.begin(), df.end(), greater<int>());
  long long l = 0, r = 1e12;
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (check(m))
      r = m - 1;
    else
      l = m + 1;
  }
  cout << l << endl;
  return 0;
}
