#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,n,m,r,d;
    cin>>a>>b>>c;
    a=abs(a);
    if(a/c>=b)
        cout<<a-b*c<<endl;
    else{
        b-=a/c;
        if(b%2==0)cout<<a%c<<endl;
        else cout<<c-(a%c)<<endl;
    }

}
