#include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e6;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
int n, k;
vector<int> a;
vector<int> b;
bool ok(int i) {
  int s = k;
  for (int j = 0; j < (int)(n); ++j) {
    if (i * a[j] > b[j]) {
      s -= (i * a[j] - b[j]);
    }
  }
  return s >= 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < (int)(n); ++i) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }
  for (int i = 0; i < (int)(n); ++i) {
    int temp;
    cin >> temp;
    b.push_back(temp);
  }
  if (n == 1) {
    cout << (b[0] + k) / a[0] << endl;
  } else {
    int low = 0;
    int high = 2222;
    while (low < high) {
      long long mid = (low + high + 1) / 2;
      if (ok(mid))
        low = mid;
      else
        high = mid - 1;
    }
    cout << low << endl;
  }
}
