unittest
{
	assert( [ "6 2 4" ].solve == 2 );
	assert( [ "7 4 3" ].solve == 1 );
	assert( [ "10 1 2" ].solve == 8 );
	assert( [ "1000000000000000 1000000000000000 1000000000000000" ].solve == 1000000000000000 );
}



import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = 0L;
	auto k = 0L;
	auto d = 0L;
	input.front.formattedRead!"%s %s %s"( x, k, d );
	
	auto c = abs( x / d );
	if( k <= c )
	{
		if( 0 < x ) return abs( x - d * k );
		else        return abs( x + d * k );
	}
	else
	{
		k -= c;
		if( 0 < x ) return abs( x - d * ( c + ( k % 2 ) ) );
		else        return abs( x + d * ( c + ( k % 2 ) ) );
	}
}
