#include <bits/stdc++.h>
using namespace std;
long long int req[100005], have[100005];
long long int n, k;
long long int calc(long long int level) {
  long long int counter = 0;
  for (int i = 0; i < n; i++) {
    if (log10(req[i]) + log10(level) > 12) return -1;
    long long int tmp1 = req[i] * level;
    long long int tmp2 = max(tmp1 - have[i], (long long int)0);
    counter += tmp2;
  }
  return counter;
}
long long int result = 0;
void bSearch(long long int from, long long int to) {
  if (from > to) return;
  long long int midPoint = (from + to) / 2;
  long long int reqMagic = calc(midPoint);
  if (reqMagic == -1) reqMagic = k + 1;
  if (reqMagic == k) {
    result = midPoint;
    return;
  } else if (reqMagic < k) {
    result = midPoint;
    return bSearch(midPoint + 1, to);
  } else
    return bSearch(from, midPoint - 1);
}
int main() {
  scanf("%I64d %I64d", &n, &k);
  long long int maxReq = 0, maxHave = 0;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &req[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &have[i]);
  }
  bSearch(0, 10000000000);
  cout << result << endl;
}
