#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a,b,k,ans = 0;
    cin >> a >> b >> k;
    ans+=((a-(a%k)+k)-a)/2;
    ans+=(b-(b-(b%k)))/2;
    ans++;
    a = a-(a%k)+k;
    b = b-(b%k);
    ans+=((b-a)/k)*((k+1)/2);
    cout << ans;
    return 0;
}
