#include #define PI 3.14159265359 using namespace std; const int64_t mod = 1e9 + 7; int main() { int L, R, M; cin >> L >> R >> M; if (R < M) { cout << R - L + 1 << endl; return 0; } else { int r, l; r = R / M; l = L / M; if (r - l >= 2) { cout << M << endl; return 0; } else { cout << R - L + 1 << endl; return 0; } } }