import java.util.Scanner;
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
while (in.hasNextInt()) { // 注意 while 处理多个 case
int n = in.nextInt();
int x = in.nextInt();
for (int i = 0; i < n; i++) {
list1.add(in.nextInt());
}
for (int i = 0; i < n; i++) {
list2.add(in.nextInt());
}
int count = 0;
for (int i = 0; i < n; i++) {
int y = list1.get(i) < list2.get(i) ? list1.get(i) : list2.get(i);
count += y;
}
if (count > x) {
System.out.println(x);
} else
System.out.println(count);
}
}
}