#include <iostream>
using namespace std;
unsigned long long a, b, ans;
int k;
int nextBorken(int a){
    while(a<b){
        if(a%k==0) return a;
        a++;
    }
    return b;
}
int main(){
    cin>>a>>b>>k;
    while(a<b){
        if(b-a<3){
            ans++;
            break;
        }
        int nxt = nextBorken(a);
        ans+=(nxt-a-1)/2+((nxt-a)%2);
        a=nxt+1;
    }
    cout<<ans<<"\n";
    return 0;
}
