def back(sushi, c, p, end):
    p += c
    h = 0
    buf = 0
    for i in range(len(sushi) - 1, end, -1):
        x, v = sushi[i]
        d = p - x
        if d < v + buf:
            h += buf + v - d
            p = x
            buf = 0
        else:
            buf += v
    return h


def forw(sushi, c, p, end):
    p -= c
    h = 0
    buf = 0
    for i in range(0, end, 1):
        x, v = sushi[i]
        d = x - p
        if d < v + buf:
            h += buf + v - d
            p = x
            buf = 0
        else:
            buf += v
    return h


def main():
    n, c = map(int, input().split())
    sushu = []
    for _ in range(n):
        x, v = map(int, input().split())
        sushu.append([x, v])

    best_h = 0
    h = 0
    p = 0
    buf = 0
    for i in range(n):
        x, v = sushu[i]
        d = x - p
        if d < v + buf:
            h += buf + v - d
            p = x
            buf = 0
            hh = h + back(sushu, c, p, i)
            best_h = max(best_h, hh)
        else:
            buf += v
    h = 0
    p = c
    buf = 0
    for i in range(n - 1, -1, -1):
        x, v = sushu[i]
        d = p - x
        if d < v + buf:
            h += buf + v - d
            p = x
            buf = 0
            hh = h + forw(sushu, c, p, i)
            best_h = max(best_h, hh)
        else:
            buf += v

    print(best_h)


main()
