
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim n, k As Int64
    Sub Main()
        Dim d, x As Int64
        Dim s() As String = ReadLine().Split
        x = s(0)
        k = s(1)
        d = s(2)
        x = Math.Abs(x)
        If x / d >= k Then
            ans = x - (k * d)
        Else
            d *= 2
            If d < x Then
                ans = x Mod d
            Else
                ans = x
            End If
            If ans >= d - ans Then
                ans = d - ans
            End If
            If k Mod 2 = 1 Then
                Dim dd As Integer = d \ 2
                ans += dd
                If ans >= Math.Abs(ans - d) Then
                    ans -= d
                End If
            End If
        End If
        WriteLine(ans)
    End Sub
End Module
