#include<iostream>
using namespace std;

long long A, B, K, br=0;

int main ()
{
    cin >> A >> B >> K;
    do
    {
        if ((A+2)%K==0)
            A++;
        else
            A+=2;
        br++;
    }
    while (A<B);
    cout << br << endl;
    return 0;
}

