//I don't want to do this....pls help!!
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vll > vvll;
typedef pair< int,int > pi;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){if(b == 0) return a;return gcd(b, a%b);}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
//modulo exponentiation
ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0)return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 
/*void BFS(int v, vector<bool>& visited){
	queue<int> q;
	q.push(v);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		cout<<u<<" ";
		visited[u]=1;
		for(auto i:adj[u]){
			if(!visited[i])q.push(i);
		}
	}
}*/
const int N=500023;
bool vis[N];
vll adj[N];

int main(){
                   // ios_base::sync_with_stdio(false);
                    //cin.tie(NULL);
                    //cout.tie(NULL);
 
                     ll t=1;
                     //cin >> t;
                     
                     while (t--){
                           ll x,k,d;cin>>x>>k>>d;
                           x=abs(x);
                           if(x%d==0){
                               if(x/d >k){
                                   cout<<x-k*d<<endl;
                               }
                               else if(x/d ==k){
                                   cout<<0<<endl;
                               }
                               else if(( k- x/d )%2==0){
                                   cout<<0<<endl;
                               }
                               else if((k- x/d )%2==1){
                                   cout<<d<<endl;
                               }
                           }
                           else{//x%d!=0
                               ll moves=(x/d);
                               if(x/d >=k){
                                   cout<<x-k*d<<endl;
                               }
                               
                               else{
                                   ll diff=k-moves;
                                   if(diff%2==0){
                                       cout<<min( x-moves*d ,abs(x-(moves +2)*d))<<endl;
                                   }
                                   else{
                                       cout<<min( x-(moves-1)*d,abs(x-(moves +1)*d))<<endl;
                                   }
                                 //  cout<<min(x-(x/d)*d , abs(x-(x/d +1)*d))<<endl;
                               }
                           }
                     }
                    cerr << endl
                                  << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                      return 0;
}


Measured memory_bytes: 15484