#include <bits/stdc++.h>
using namespace std;
int a[1005], b[1005];
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  int l = 0, r = 1e5 + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    int cost = 0;
    for (int i = 1; i <= n; i++) {
      int use = mid * a[i];
      if (use > b[i]) cost += use - b[i];
    }
    if (cost > k)
      r = mid;
    else
      l = mid;
  }
  cout << l;
  return 0;
}
