#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (scanf("%d %d", &n, &k) == 2) {
    vector<int> a, b;
    a.assign(n, 0);
    b.assign(n, 0);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    int ans = 0;
    while (true) {
      bool masihBisa = true;
      for (int i = 0; i < n; i++) {
        if (b[i] < a[i] && k) {
          if (a[i] - b[i] <= k) {
            int banyak = a[i] - b[i];
            b[i] += a[i] - b[i];
            k -= banyak;
          } else {
            b[i] += k;
            k = 0;
          }
        }
        if (b[i] < a[i]) {
          masihBisa = false;
          break;
        }
      }
      if (!masihBisa) break;
      int minimum = 1e9;
      for (int i = 0; i < n; i++) {
        minimum = min(minimum, b[i] / a[i]);
      }
      for (int i = 0; i < n; i++) {
        b[i] -= a[i] * minimum;
      }
      ans += minimum;
    }
    printf("%d\n", ans);
  }
  return 0;
}
