
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto abck = readln.split.map!( to!long );
	writeln( solve( abck[ 0 ], abck[ 1 ], abck[ 2 ], abck[ 3 ] ) );
}

long solve( in long a, in long b, in long c, in long k )
{
	if( k % 2 == 0 ) return a - b;
	else             return b - a;
}

unittest
{
	assert( solve( 1, 2, 3, 1 ) == 1 );
	assert( solve( 2, 3, 2, 0 ) == -1 );
	assert( solve( 1000000000, 1000000000, 1000000000, 1000000000000000000 ) == 0 );
}
