// 提出時にassertはオフ #ifndef DEBUG #ifndef NDEBUG #define NDEBUG #endif #endif #include using namespace std; using ll = long long; #define ALL(x) (x).begin(), (x).end() template using vec = vector; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll L, R, C; cin >> L >> R >> C; if(R - L >= 1000) { cout << 0 << "\n"; return 0; } ll ans = 1000; for(ll x = L; x <= R; x++) { ans = min(ans, ((x * C + 999) / 1000) * 1000 - x * C); } cout << ans << "\n"; }