#include<iostream>
using namespace std;
#define LL long long int
int main()
{
     LL a, b;
     long long k, skoci=0;
     cin>>a>>b>>k;
     while(a<b)
     {
         //cout<<a<<" -> ";
         if((a+2)%k==0 or a+1==b)
         {
             a++;
             skoci++;
         }
         else
         {
             a+=2;
             skoci++;
         }
         //cout<<a<<endl;
     }
     cout<<skoci<<"\n";

    return 0;
}
