import java.io.*;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int n = nextInt();
int m = nextInt();
int[] k = new int[n];
int[] c = new int[n];
for (int i = 0; i < n; i++) {
k[i] = nextInt();
}
int totalMoney = 0;
for (int i = 0; i < n; i++) {
c[i] = nextInt();
totalMoney += c[i] * k[i];
}
long[] dpArray = new long[totalMoney + 1];
Arrays.fill(dpArray, 1);
for (int i = 0; i < n; i++) {
for (int j = totalMoney; j >= c[i] ; j--) {
for (int l = 1; l <= k[i] && l * c[i] <= j; l++) {
long newVal = dpArray[j - l * c[i]] * l;
if(newVal > dpArray[j] && dpArray[j]<m){
dpArray[j] = newVal;
}
}
}
}
for (int i = 1; i <= totalMoney; i++) {
if(dpArray[i] >= m){
out.println(i);
break;
}
}
out.close();
}
static StreamTokenizer stk = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static int nextInt() {
try {
stk.nextToken();
} catch (IOException e) {
e.printStackTrace();
}
return (int) stk.nval;
}
}