#include <iostream>

using namespace std;

int main() {
    long long a, b, k;

    cin >> a >> b >> k;

    long long jumps = 0;
    while (a < b) {
        if ((a + 2) % k == 0 || a + 1 == b) {
            a+=1;
        } else {
            a+=2;
        }
        jumps++;
    }

    cout << jumps << endl;

    return 0;
}
