#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long a, b, k;
    cin>>a>>b>>k;
    long long last, br=0, first;

    if(a%2==b%2){
        br=(b-a)/2;
        first=a+k-a%k;
        last=b-b%k;
        while(first<b){
            if(first%2==a%2){
                br++;
            }
            first=first+k;
        }
    }

    if(a%2!=b%2){
        br=(b-a)/2+1;
        first=a+k-a%k;
        last=b-b%k;
        while(first<b){
            if(first%2==a%2){
                br++;
            }
            first=first+k;
        }
    }

    cout<<br<<"\n";

    return 0;
}


