#include <bits/stdc++.h>
using namespace std;
long long fact(long long n) { return (n == 1 || n == 0) ? 1 : n * fact(n - 1); }
long long absol(long long n) {
  if (n < 0) n = -n;
  return n;
}
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long binaryToDecimal(long long n) {
  long long num = n;
  long long dec_value = 0;
  long long base = 1;
  long long temp = num;
  while (temp) {
    long long last_digit = temp % 10;
    temp = temp / 10;
    dec_value += last_digit * base;
    base = base * 2;
  }
  return dec_value;
}
string binary = bitset<8>(5).to_string();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k, mini = 999999, mag = 0;
  cin >> n >> k;
  long long a[n], b[n];
  for (long long j = 0; j < n; ++j) {
    cin >> a[j];
  }
  for (long long j = 0; j < n; j++) {
    cin >> b[j];
    mini = min(mini, b[j] / a[j]);
  }
  long long j = -1;
  while (k > 0) {
    j = (++j) % n;
    if (b[j] / a[j] < mini) {
      mag += a[j];
    }
    if (b[j] / a[j] == mini) mag += (a[j] - b[j] % a[j]);
    if (j == n - 1) {
      if (k >= mag) {
        mini++;
        k -= mag;
      } else {
        k -= mag;
      }
      mag = 0;
    }
  }
  cout << mini << endl;
  return 0;
}
