import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
static int N = (int)(2e5 + 10);
static int mx = Integer.MAX_VALUE;
static int n;
static long k;
static int[] w = new int[N], h = new int[N];
static void solve() {
n = in.nextInt();
k = in.nextLong();
for (int i = 0; i < n; i++) {
w[i] = in.nextInt();
}
for (int i = 0; i < n; i++) {
h[i] = in.nextInt();
}
int[][] t = new int[n][2];
for (int i = 0; i < n; i++) {
t[i][0] = w[i];
t[i][1] = h[i];
}
Arrays.sort(t, new Comparator<int[]>() {
public int compare(int[] o1, int[] o2) {
return o1[0] - o2[0];
}
});
int l = 0;
int r = 0;
long sum = 0L;
if (t[r][1] >= k) {
System.out.print(0);
return;
}
while (r != n) {
while (r != n && sum < k) {
sum += t[r][1];
r++;
}
while (sum >= k) {
mx = Math.min(mx, t[r - 1][0] - t[l][0]);
sum -= t[l][1];
l++;
}
}
if (mx != Integer.MAX_VALUE) {
System.out.print(mx);
return;
}
out.println(-1);
}
public static void main(String[] args) {
solve();
out.flush();
}
static FastReader in = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
static class FastReader {
static BufferedReader br;
static StringTokenizer st;
FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
String str = "";
while (st == null || !st.hasMoreElements()) {
try {
str = br.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
st = new StringTokenizer(str);
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
}