#include using namespace std; int main() { int L,R,C,A; A = 1000; cin >> L >> R >> C; for (int i = L; i < R+1; i++){ if (A > (i * C / 1000 + 1) * 1000 - i * C) { A = (i * C / 1000 + 1) * 1000 - i*C; } } cout << A << endl; return 0; }