#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < int(n); ++i) cin >> a[i].second;
  int mn = 0;
  for (int i = 0; i < int(n); ++i) cin >> a[i].first;
  multiset<pair<int, int>> ms;
  for (int i = 0; i < int(n); ++i) {
    ms.insert({a[i].first / a[i].second, i});
  }
  while (k) {
    if (k == 0) break;
    auto x = *ms.begin();
    int l = a[x.second].first - (a[x.second].second * x.first);
    l = a[x.second].second - l;
    if (k >= l) {
      a[x.second].first += l;
      x.first = a[x.second].first / a[x.second].second;
      ms.erase(ms.begin());
      ms.insert(x);
      k -= l;
      continue;
    }
    break;
  }
  cout << ms.begin()->first;
}
