#include <bits/stdc++.h>
using namespace std;
const unsigned long long mxN = 10e9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  unsigned long long n, k, cnt = 0, ans = 0;
  cin >> n >> k;
  unsigned long long a[n], b[n];
  for (unsigned long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (unsigned long long i = 0; i < n; ++i) {
    cin >> b[i];
  }
  unsigned long long l = 0, r = mxN, cur;
  while (r - l > 1) {
    cur = (l + r) / 2;
    cnt = 0;
    for (unsigned long long i = 0; i < n; ++i) {
      if (a[i] * cur > b[i]) cnt += a[i] * cur - b[i];
    }
    if (cnt > k)
      r = cur;
    else
      l = cur;
  }
  cout << l << "\n";
}
