n, l = list(map(int,input().split()))

ai = [[int(eval(input())),i] for i in range(n)]



ai.sort(key = lambda x: x[0])

time = [0]*(n+2)

for i in ai:

    idx = i[1]

    time[idx+1] = max(time[idx],time[idx+2]) + l - i[0]



print((max(time)))
n, l = list(map(int,input().split()))

#ai = [[int(input()),i] for i in range(n)]

ai = [[] for _ in range(l)]

for i in range(n):

    ai[int(eval(input()))].append(i)

time = [0]*(n+2)



for i in range(l-1,0,-1):

    for j in ai[i]:

        time[j+1] = max(time[j],time[j+2]) + l - i



print((max(time)))
n, l = list(map(int, input().split()))
ai = [[int(eval(input())), i] for i in range(n)]
ai.sort(key=lambda x: x[0])
time = [0] * (n + 2)
for i in ai:
    idx = i[1]
    time[idx + 1] = max(time[idx], time[idx + 2]) + l - i[0]
print((max(time)))

n, l = list(map(int, input().split()))
# ai = [[int(input()),i] for i in range(n)]
ai = [[] for _ in range(l)]
for i in range(n):
    ai[int(eval(input()))].append(i)
time = [0] * (n + 2)
for i in range(l - 1, 0, -1):
    for j in ai[i]:
        time[j + 1] = max(time[j], time[j + 2]) + l - i
print((max(time)))

-ai = [[int(eval(input())), i] for i in range(n)] -ai.sort(key=lambda x: x[0]) +# ai = [[int(input()),i] for i in range(n)] +ai = [[] for _ in range(l)] +for i in range(n): +    ai[int(eval(input()))].append(i) -for i in ai: -    idx = i[1] -    time[idx + 1] = max(time[idx], time[idx + 2]) + l - i[0] +for i in range(l - 1, 0, -1): +    for j in ai[i]: +        time[j + 1] = max(time[j], time[j + 2]) + l - i