#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[1005];
int suma;
int b[1005];
int sumb;
int main() {
  suma = sumb = 0;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    suma += a[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    sumb += b[i];
  }
  int start = 0x7fffffff;
  for (int i = 1; i <= n; i++) {
    start = min(start, b[i] / a[i]);
  }
  int end = (sumb + k) / suma;
  int ans = start;
  for (int i = start; i <= end; i++) {
    int sum = 0;
    for (int j = 1; j <= n; j++) {
      sum += max(0, a[j] * i - b[j]);
    }
    if (sum <= k) ans = i;
  }
  printf("%d\n", ans);
  return 0;
}
