#include<iostream>
using namespace std;

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

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

