import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static List values = new ArrayList<>(); static List costs = new ArrayList<>(); static int[][] dp; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int target = sc.nextInt(); int[] current = new int[n]; for (int i = 0; i < n; i++) { current[i] = target - sc.nextInt(); } int total = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); if (current[i] <= 0) { total -= current[i]; } else { values.add(current[i]); costs.add(x); } } if (values.size() == n) { System.out.println(-1); return; } dp = new int[values.size()][total + 1]; for (int[] arr : dp) { Arrays.fill(arr, -1); } System.out.println(dfw(values.size() - 1, total)); } static int dfw(int idx, int v) { if (v < 0) { return Integer.MAX_VALUE / 2; } if (idx < 0) { return 0; } if (dp[idx][v] < 0) { dp[idx][v] = Math.min(dfw(idx - 1, v) + costs.get(idx), dfw(idx - 1, v - values.get(idx))); } return dp[idx][v]; } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }