use proconio::input;

fn main() {
    input!(n: usize, c: i64, xv: [(i64, i64); n]);
    let x: Vec<_> = std::iter::once(0)
        .chain(xv.iter().map(|&(x, _)| x))
        .chain(std::iter::once(c))
        .collect();
    let v: Vec<_> = std::iter::once(0)
        .chain(xv.iter().map(|&(_, v)| v).scan(0, |state, v| {
            *state += v;
            Some(*state)
        }))
        .chain(std::iter::once(xv.iter().map(|&(_, v)| v).sum::<i64>()))
        .collect();
    let n = n + 1;

    let mut ans = 0;
    let mut once = std::i64::MIN;
    let mut twice = std::i64::MIN;
    for i in (1..n).rev() {
        once = once.max(-v[i] + x[i + 1]);
        twice = twice.max(-v[i] + 2 * x[i + 1]);
        ans = ans.max(v[i] + v[n] - 2 * x[i] - x[n] + once);
        ans = ans.max(v[i] + v[n] - x[i] - 2 * x[n] + twice);
    }
    println!("{}", ans);
}
