
fun main(arr:Array<String>) {
    val (n,l) = readLine()!!.split(" ").map { it.toInt() }
    val apples = (0 until n).map { it + l }
    val applePie = apples.sum()
    var ans = apples.map { applePie - it }.sortedBy { Math.abs(applePie - it) }
    println(ans[0])
}

