#include<iostream>
using namespace std;
int main()
{
    long long br=0,a,b,k;
    cin>>a>>b>>k;
    long long tek=a,m=a;
    if(a%2!=b%2 || k>b)
    {
        while(tek<b)
        {
            br++;
            tek+=2;
        }
    }else{
    if(k<b){
    while(m<b)
    {
        m+=k;
        br+=k/2;
    }
    }
    }

    cout<<br<<endl;
    return 0;
}
