import static java.lang.Math.*; import static java.math.BigInteger.*; import static java.util.Arrays.*; import static java.util.Collections.*; import java.math.*; import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { new Main().run(); } Scanner in = new Scanner(System.in); void _out(Object...os) { System.out.println(deepToString(os)); } void _err(Object...os) { System.err.println(deepToString(os)); } void run() { long INF = 1_000_000_000_000_000_000L + 1; for (; in.hasNext(); ) { int n = in.nextInt(); long m = in.nextLong(); int[] as = new int[n]; for (int i = 0; i < n; ++i) { as[i] = in.nextInt(); } long[] ks = new long[n]; for (int i = 0; i < n; ++i) { ks[i] = in.nextLong(); } int lim = as[n - 1] << 1; long[] dp; for (; ; lim <<= 1) { dp = new long[lim + 1]; for (int x = 0; x <= lim; ++x) { dp[x] = INF; } dp[0] = 0; for (int i = 0; i < n; ++i) { for (int x = as[i]; x <= lim; ++x) { if (dp[x] > dp[x - as[i]] + 1) { dp[x] = dp[x - as[i]] + 1; } } } boolean ok = true; for (int x = lim - as[n - 1]; x <= lim; ++x) { ok &= (dp[x] >= INF || dp[x] == dp[x - as[n - 1]] + 1); } if (ok) { break; } } _err(lim); long target = -m; for (int i = 0; i < n; ++i) { target += as[i] * ks[i]; } long ans; if (target < 0) { ans = INF; } else if (target <= lim) { ans = dp[(int)target]; } else { long greed = ((target - lim) + as[n - 1] - 1) / as[n - 1]; ans = greed + dp[(int)(target - as[n - 1] * greed)]; } System.out.println((ans >= INF) ? -1 : ans); } } }