#include <bits/stdc++.h>
using namespace std;

int n, budget;
vector<int> req, cost, stock;

bool check(int units){
    int cst = 0;
    for(int i = 0; i < n; i++){
    	if(stock[i] < req[i]*units)
        cst = cst + ((req[i]*units) - stock[i])*cost[i];
    }
    if(cst > budget)
    return false;
    else
    return true;
}

int main() 
{
    
    cin >> n >> budget;
    req.resize(n);
    cost.resize(n);
    stock.resize(n);
    
    for(int i = 0; i < n; i++)
    cin >> req[i];
    for(int i = 0; i < n; i++)
    cin >> stock[i];
    int tot_cost = 0;
    for(int i = 0; i < n; i++){
    cin >> cost[i];
    tot_cost += cost[i];
    }
    int min_prod = INT_MAX;
	for(int i = 0; i < n; i++){
		min_prod = min(min_prod, stock[i]/req[i]);
	}
    int lo = 0;
    int hi = budget+min_prod;
    
    int ans = -1;
    while(lo <= hi){
        int mid = (lo+hi)/2;
        if(check(mid)){
            ans = mid;
            lo = mid+1;
        }
        else
        hi = mid-1;
    }

    cout << ans;

    return 0;
}