#include <bits/stdc++.h>
using namespace std;
long long size, k;
long long a[1001], b[1001];
bool can(long long x) {
  long long count = 0;
  for (int i = 0; i < size; i++) {
    if ((a[i] * x) > b[i]) {
      count += (a[i] * x) - b[i];
    }
  }
  if (count > k) {
    return false;
  } else {
    return true;
  }
}
int main() {
  cin >> size >> k;
  for (int i = 0; i < size; i++) {
    cin >> a[i];
  }
  long long minn = 1001;
  for (int i = 0; i < size; i++) {
    cin >> b[i];
    if (b[i] < minn) {
      minn = b[i];
    }
  }
  long long l = 0;
  long long r = minn + k;
  long long mid, result;
  while (l <= r) {
    mid = (l + r) / 2;
    if (can(mid)) {
      l = mid + 1;
      result = mid;
    } else
      r = mid - 1;
  }
  cout << result << endl;
  return 0;
}
