#include <bits/stdc++.h>
using namespace std;
long long necesar[100010], av[100010];
long long k;
int n;
bool f(long long x);
int main() {
  ios_base::sync_with_stdio(false);
  int magic;
  cin >> n >> magic;
  for (int i = 0; i < n; i++) {
    cin >> necesar[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> av[i];
  }
  long long p = 0, q = (1ll << 33);
  while (q > 0) {
    k = magic;
    if (f(q + p)) p += q;
    q /= 2;
  }
  cout << p;
  return 0;
}
bool f(long long x) {
  for (int i = 0; i < n; i++) {
    if (av[i] < x * necesar[i]) {
      k += (long long)av[i] - x * necesar[i];
      if (k < 0) return false;
    }
  }
  return true;
}
