N, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) if N == 1: print(0) else: max_time = 0 # Handle j=2 time_j2 = A[0] + B[1] max_time = time_j2 if N == 2: print(max_time) exit() prev_prev = 0 # time for j-2=1 prev = time_j2 # time for j-1=2 max_time = max(max_time, prev) for j in range(3, N + 1): # j is current employee (1-based) # j-2 is the index in A for employee j-2 (0-based) a_j_minus_1 = A[j-2] # A[j-2] corresponds to employee j-1's A_i b_j = B[j-1] # B[j-1] is employee j's B_i condition1 = prev + a_j_minus_1 + b_j a_j_minus_2 = A[j-3] if j-3 >= 0 else 0 # j >=3 implies j-3 >=0 when j starts from 3 condition2 = prev_prev + a_j_minus_2 + b_j + K current = min(condition1, condition2) max_time = max(max_time, current) # Update previous values prev_prev, prev = prev, current print(max_time)