/*

    Author      : Yash Sharma
    Institution : IIT Patna
    Country     : India

*/


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

typedef long long ll;
typedef long double ld;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
//#define mpq priority_queue<int,vector<int>,greater<int>>
#define debug(a) cerr << #a << ": " << a << endl
#define umii unordered_map<int64_t,int64_t>
#define ftt int t;cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end());
#define Sort(v) sort(v.begin(),v.end());
#define Sum(v) accumulate(v.begin(),v.end(),0)
#define Input(v) for(auto &x:v)cin>>x;
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define sayy cout<<"YES\n"
#define sayn cout<<"NO\n"
#define int long long
#define double long double
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define eb emplace_back
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define snd second
#define fst first

const int INF = numeric_limits<int>::max();
const int MOD = 1000000007;
const double PI = 3.1415926535898;
const int LIM = 100005;

int fpow( int x,int y) {
    int temp;
    if(y == 0)
        return 1;
    temp = fpow(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;}

int gcd(int a,int b) {
    if(b==0)return a;
    return gcd(b,a%b);}

void sieve(int n) {
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p=2; p*p<=n; p++)
          if (prime[p] == true)
               for (int i=p*p; i<=n; i += p)
                    prime[i] = false;
     prime[1]=0;}

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

map<int,int> primeFactors(int n)
{
    map<int, int> mp;
    while (n % 2 == 0)
    {
        if(mp.count(2) == 1)
            mp[2]++;
        else
            mp.insert({2,1});
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            if(mp.count(i) == 1)
                mp[i]++;
            else
                mp.insert({i,1});
            n = n/i;
        }
    }
    if (n > 2)
    {
        if(mp.count(n) == 1)
            mp[n]++;
        else
            mp.insert({n,1});
    }
    return mp;
}

bool flag = true;
int maxi = 4294967295;

int fun(vi v)
{
    int ret = 1;
    for(int x : v)
    {
        ret *= x;
        if(ret > maxi)
        {
            flag = false;
            return 0;
        }
    }
    return  ret;
}


//*************************************************************************************************************************


int32_t main()
{    fio;

    int x, k, d;
    cin>>x>>k>>d;
    int steps = (abs(x) / (double)d);
    if(steps > k)
    {
        if(x > 0)
            x -= k*d;
        else
            x += k*d;
    }
    else
    {
        steps = floor(steps);
        if(x > 0)
            x -= steps*d;
        else
            x += steps*d;
        k -= steps;
        if(k > 0)
        {
            if(x >= 0)
                x -= (k%2) * d;
            else
                x += (k%2) * d;
        }
    }
    x = abs(x);
    cout<<x;
    return 0;
}


Measured memory_bytes: 3608