#include <iostream>

using namespace std;

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

    cin >> a >> b >> k;

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

    cout << jumps << endl;

    return 0;
}
