#include <bits/stdc++.h>
#pragma warning(disable : 4996)
int n, k;
int a[1000];
int b[1000];
int q[1000];
int r[1000];
int total = 0;
int min, ans = 0;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) scanf("%d", b + i);
  for (int i = 0; i < n; i++) total += a[i];
  for (int i = 0; i < n; i++) {
    q[i] = b[i] / a[i];
    r[i] = b[i] % a[i];
  }
  int before_k;
  while (k >= 0) {
    min = 1000000001;
    for (int i = 0; i < n; i++) {
      if (q[i] < min) min = q[i];
    }
    for (int i = 0; i < n; i++) q[i] -= min;
    ans += min;
    before_k = k;
    for (int j = 0; j < n; j++) {
      if (q[j] == 0 && a[j] - r[j] <= k) {
        q[j]++;
        k -= a[j] - r[j];
        r[j] = 0;
      }
    }
    if (before_k == k) break;
  }
  printf("%d\n", ans);
  return 0;
}
