#include <iostream>

using namespace std;

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

    cin >> a >> b >> k;

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

    cout << jumps << endl;

    return 0;
}
