import java.util.*;
import java.io.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int k = Integer.parseInt(br.readLine());
        int m = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] c = new int[200];
        int[] p = new int[200];
        int n = st.countTokens();
        for(int i=0;i<n;i++){
            c[i]=Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        n=st.countTokens();
        for(int i=0;i<n;i++){
            p[i]=Integer.parseInt(st.nextToken());
        }
        List<Integer> deleteIndex = new ArrayList<>();
        int credit=m;
        for(int i=0;i<k;i++){
            int maxProfit=-1;
            int index = -1;
            for(int x=0;x<c.length;x++){
                //该商品已经售出
                if(deleteIndex.contains(x)){
                    continue;
                }
                //小于等于成本,成本+利润最大化
                if(c[x]<=credit && p[x]>maxProfit){
                    maxProfit=p[x];
                    index=x;
                }
            }
            if(index!=-1){
                credit+=p[index];
                deleteIndex.add(index);
            }
        }
        System.out.println(credit-m);
    }
}