#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long a,b;
    int k,br=0;
    cin>>a>>b>>k;
    while(a<b)
    {
        if((a+2)%k!=0)
        {
            a+=2;
            br++;
        }
        else
        {
            a++;
            br++;
        }
    }
    cout<<br;
}
