#include <iostream>
#include<bits/stdc++.h>

using namespace std;
bool check(vector<int> &throughput , vector<int> &cost , int mid , int budget){
	int n = cost.size();
	int sum=0;
	
	for(int i=0;i<n;i++){
        int a = (mid-1)/throughput[i];
        int c = cost[i]*a;
        sum+=c;
	}
	
	return sum<=budget;
	
}
int main() {
	// your code goes here
	int n,budget;
	cin>>n>>budget;
	vector<int> throughput(n);
	vector<int> cost(n);
	for(int i=0;i<n;i++){
		cin>>throughput[i];
	}
	
	for(int i=0;i<n;i++){
		cin>>cost[i];
	}
	
	
	int low = 1;
	int high = 1e9;
	int ans=-1;
	
	while(low<=high){
		int mid = (low+high)/2;
		if(check(throughput,cost,mid,budget)==true){
			ans=mid;
			low=mid+1;
		}
		else{
			high = mid-1;
			
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}