#include <bits/stdc++.h>
using namespace std;
long n, k, a[10000], b[10000];
long tong = 0;
long dem = 0;
long check(long l) {
  long zzz = 0;
  for (long i = 0; i < n; i++) {
    zzz += max(0L, a[i] * l - b[i]);
  }
  if (zzz <= k)
    return true;
  else
    return false;
}
long bsearch(long l, long r) {
  long mid = (l + r) / 2;
  while (l != r) {
    if (check(mid) == 1)
      l = mid + 1;
    else
      r = mid;
    mid = (l + r) / 2;
  }
  return l - 1;
}
int main() {
  cin >> n >> k;
  for (long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long i = 0; i < n; i++) {
    cin >> b[i];
  }
  cout << bsearch(1, 10000);
}
