#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long arr1[1000000], arr2[1000000], mid, l = 1, r = 2005, ans = 0;
long long Solve(long long x) {
  long long m2 = m;
  for (long long a = 0; a < n; a++) {
    if ((mid * arr1[a]) > arr2[a]) m2 -= (mid * arr1[a]) - arr2[a];
  }
  if (m2 < 0) return 0;
  return 1;
}
long long BS() {
  while (l <= r) {
    mid = (l + r) / 2;
    if (Solve(mid)) {
      ans = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> arr1[i];
  for (long long i = 0; i < n; i++) cin >> arr2[i];
  cout << BS() << endl;
  return 0;
}
