program sample
  implicit none
  integer N, L, M, k, i, j, e
  read(*,*) N, L
  M = 0
  do i =1, N
  M = M + L + i - 1
  end do
  if ( abs(M - 2 * L - 2 * N + 2) >= abs( M - 2 * L )) then
   k = abs(M - 2 * L - 2 * N + 2)
  else
   k = abs( M - 2 * L )
  endif
  do j = 1, N
   if (  abs( M - 2 * L - 2 * j + 2) < k) then
    k = abs(M - L - j + 1)
    e = j
   endif
  end do
  write(*,*) M - L - e + 1 
  stop
end program sample 