#include #include using namespace std; using lint=int64_t; int main() { lint L,R,M; cin >> L >> R >> M; lint LL=L%M; lint RR=R%M; if(RR-LL>=0)cout << RR-LL+1; else cout << M-LL+RR+1; cout << endl; return 0; }