#include <bits/stdc++.h>
using namespace std;
long long int a[100000], b[100000];
bool pred(long long int n, long long int k, long long int mid) {
  for (int i = 0; i < n; i++) {
    if ((b[i] - (mid * a[i])) < 0) {
      k = k - ((mid * a[i]) - b[i]);
    }
    if (k < 0) return false;
  }
  return true;
}
int main() {
  long long int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  long long int hi = 1000000000;
  long long int lo = 0;
  long long int mid;
  while (hi > lo) {
    mid = (hi + lo) / 2 + 1;
    if (pred(n, k, mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  cout << lo;
  return 0;
}
