#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long nd[n], is[n];
  for (int i = 0; i < n; ++i) {
    cin >> nd[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> is[i];
  }
  vector<pair<long long, pair<long long, long long>>> p(n);
  for (int i = 0; i < n; ++i) {
    p[i] = make_pair(is[i] / nd[i], make_pair(nd[i], is[i]));
  }
  sort(p.begin(), p.end());
  long long req = 0;
  int i = 0;
  while (true) {
    req += p[i].second.first;
    long long nxt = p[i + 1].first;
    k += p[i].second.second % p[i].second.first;
    if (i == n - 1) {
      p[i].first += k / req;
      break;
    }
    long long needed = (p[i + 1].first - p[i].first) * req;
    if (k >= needed) {
      k -= needed;
      ++i;
    } else {
      p[i].first += k / req;
      break;
    }
  }
  cout << p[i].first;
}
