#include <bits/stdc++.h>
const long double pi = 3.1415926535;
const long double EPS = 1e-8;
using namespace std;
void ch4() {
  int n;
  long long k;
  cin >> n >> k;
  long long a[n], b[n], c[n];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long kol = a[0] / b[0];
  for (int i = 0; i < n; ++i) {
    c[i] = a[i] / b[i];
    a[i] -= b[i] * c[i];
    kol = min(kol, c[i]);
  }
  long long ans = kol;
  while (k >= 0) {
    ++ans;
    for (int i = 0; i < n; ++i) {
      if (c[i] < ans) {
        k += a[i];
        a[i] = 0;
        k -= b[i];
        ++c[i];
      }
    }
  }
  cout << ans - 1;
}
int main() {
  ch4();
  return 0;
}
