(n, c)  = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }

xv = []

sum_r = []
sum_r2 = []
sum = 0
sum2 = 0
p = 0
n.times do
  (x, v) = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }
  xv.push [x, v]

  sum = sum + v - (x - p)
  sum2 = sum2 + v - 2 * (x - p)
  p = x
  sum_r.push sum
  sum_r2.push sum2
end

sum_l = []
sum_l2 = []
sum = 0
sum2 = 0
p = c
n.times do |i|
  (x, v) = xv[n - i - 1]

  sum = sum + v - (p - x)
  sum2 = sum2 + v - 2 * (p - x)
  p = x
  sum_l.push sum
  sum_l2.push sum2
end

cal_max = 0
n.times do |i|
  if i == 0
    cal = sum_l.max
  elsif i == n - 1
    cal = sum_r.max
  else
    cal1 = sum_r2[0..(i - 1)].max + sum_l[0..(n - i - 1)].max
    cal2 = sum_r[0..(i - 1)].max + sum_l2[0..(n - i - 1)].max
    cal3 = sum_r[0..(i - 1)].max
    cal4 = sum_l[0..(n - i - 1)].max
    cal = [cal1, cal2, cal3, cal4].max
  end

  if cal_max < cal
    cal_max = cal
  end
end

p cal_max
