#include <bits/stdc++.h>
using namespace std;
long long a, s, d[100002], f[100002], g, h, j, k, l, i, n, m;
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> d[i];
  }
  for (i = 0; i < n; i++) {
    cin >> f[i];
  }
  h = 5000000000;
  while (h - g > 1) {
    k = (h + g) / 2;
    s = m;
    j = 1;
    for (i = 0; i <= n; i++) {
      if (k * d[i] > f[i]) {
        s -= k * d[i] - f[i];
        if (s < 0) {
          j = 0;
          break;
        }
      }
    }
    if (j)
      g = k;
    else
      h = k;
  }
  cout << g;
  return 0;
}
