#include <bits/stdc++.h>
using namespace std;
int need[1001], have[1001], n, mb;
bool canWeBake(int k) {
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    if (k * need[i] > have[i]) sum += k * need[i] - have[i];
  }
  return sum <= mb;
}
int bs() {
  int st = 0, en = 5e3, mid;
  while (st < en) {
    mid = (st + en + 1) / 2;
    if (canWeBake(mid))
      st = mid;
    else
      en = mid - 1;
  }
  return st;
}
int main() {
  cin >> n >> mb;
  for (int i = 0; i < n; ++i) cin >> need[i];
  for (int i = 0; i < n; ++i) cin >> have[i];
  for (int i = 5000; i >= 0; i--)
    if (canWeBake(i)) return cout << i << endl, 0;
  return 0;
}
