#include <iostream>

using namespace std;

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

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

    cin >> a >> b >> k;

    cout << obrabotka(a, b, k) << endl;

    return 0;
}
