#include <iostream>

using namespace std;

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

    cin >> a >> b >> k;

    //a = 1000000000000000000;

    //cout << a;

    long long jumps = 0;/*
    while (a < b) {
        if ((a + 2) % k == 0 || a + 1 == b) {
            a+=1;
        } else {
            a+=2;
        }
        jumps++;
    }*/
    int br = 0;
    for (long long i = a; i < b; i++) {
        if (i % k == 0) {
            br++;
        }
    }

    cout << (b - a - br) / 2 + (b - a) % 2 << endl;

    return 0;
}
