#include <bits/stdc++.h>
using namespace std;
int need[1008];
int have[1008];
int tmpp[1008];
int n, k;
int slove(int mid) {
  for (int i = 1; i <= n; i++) {
    tmpp[i] = have[i] - mid * need[i];
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (tmpp[i] < 0) sum += -tmpp[i];
  }
  if (sum <= k)
    return 1;
  else
    return 0;
}
int main() {
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &need[i]);
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &have[i]);
    }
    int ans = 0;
    int mid;
    int l = 0;
    int r = 10000;
    while (r >= l) {
      mid = (l + r) / 2;
      if (slove(mid) == 1) {
        ans = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
