#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
long long a[200005];
long long b[200005];
int r[200005];
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.first > b.first;
  }
};
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> pq;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    r[i] = b[i] / a[i];
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    c = min(c, r[i]);
  }
  for (int i = 0; i < n; i++) {
    b[i] -= (c * a[i]);
    r[i] -= c;
  }
  for (int i = 0; i < n; i++) {
    pq.push(pair<int, int>(r[i], i));
  }
  pair<int, int> t;
  while (k) {
    if (k >=
        (((pq.top().first + 1) * a[pq.top().second]) - b[pq.top().second])) {
      k -= (((pq.top().first + 1) * a[pq.top().second]) - b[pq.top().second]);
      b[pq.top().second] = ((pq.top().first + 1) * a[pq.top().second]);
      t = pq.top();
      pq.pop();
      t.first += 1;
      pq.push(t);
    } else {
      break;
    }
  }
  c += (pq.top().first);
  cout << c << endl;
}
