#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6 + 7;
int a[1010], b[1010];
int n, k;
bool check(int d) {
  int tmp;
  int hub = k;
  for (int i = 0; i < n; i++) {
    tmp = b[i] - a[i] * d;
    if (tmp < 0) hub += tmp;
    if (hub < 0) return false;
  }
  return true;
}
int main() {
  while (~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]);
    int lb = 0, ub = inf;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (check(mid))
        lb = mid;
      else
        ub = mid;
    }
    printf("%d\n", lb);
  }
  return 0;
}
