#include<iostream>
using namespace std;
int main()
{
    long long br=0,a,b,k;
    cin>>a>>b>>k;
    long long tek=a;
    for(;tek<b;br++)
    {
        if(tek+2%k==0 && tek+2!=b)
        {
            tek++;
        }else{
        tek+=2;
        //cout<<tek<<" ";
        }
    }
    cout<<br<<endl;
    return 0;
}
// a=1,b=3,k=12 1
// a=2,b=18,k=3

