#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    long long a,b,c,sum,k;
    cin>>a>>b>>c;
    cin>>k;
    k%=2;
    cout<< (long long) ((b-a)*(2*k-1)) <<endl;
    return 0;
}
