import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int k = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); int[] b = new int[n]; for (int i = 0; i < n; i++) { b[i] = Integer.parseInt(sa[i]); } br.close(); long[] dp = new long[n]; for (int i = 1; i < n; i++) { dp[i] = dp[i - 1] + a[i - 1] + b[i]; if (i > 1) { long val = dp[i - 2] + a[i - 2] + b[i] + k; dp[i] = Math.min(dp[i], val); } } long ans = 0; for (int i = 0; i < dp.length; i++) { ans = Math.max(ans, dp[i]); } System.out.println(ans); } }