#include <bits/stdc++.h>
using namespace std;
vector<long long> a, b;
long long p;
bool check(long long q) {
  long long m = p;
  for (int i = 0; i < a.size(); i++) {
    if (b[i] / a[i] >= q)
      continue;
    else {
      long long R = q * a[i] - b[i];
      if (m >= R)
        m -= R;
      else
        return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    long long k;
    cin >> k;
    a.push_back(k);
  }
  for (int i = 0; i < n; i++) {
    long long k;
    cin >> k;
    b.push_back(k);
  }
  long long l = 0, r = 1e5 + 7, ans = 0;
  while (l <= r) {
    long long ma = (l + r) / 2;
    if (check(ma)) {
      ans = ma;
      l = ma + 1;
    } else
      r = ma - 1;
  }
  cout << ans;
}
