#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long a[100000], b[100000];
long long fun(long long x) {
  long long def = 0;
  for (long long i = 1; i <= n; i++) {
    if (b[i] < x * a[i]) {
      def += x * a[i] - b[i];
    }
  }
  if (def - k <= 0) {
    return false;
  } else {
    return true;
  }
}
int32_t main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> b[i];
  }
  long long l = 0;
  long long r = 3000000001;
  while (r - l > 1) {
    long long mid = l + (r - l + 1) / 2;
    if (fun(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << l;
  return 0;
}
