#include using namespace std; using ll = long long; using db = long double; using ch = char; using bl = bool; using st = string; using pll = pair; using psl = pair; using vst = vector; using vch = vector; using vvch = vector; using vbl = vector; using vvbl = vector; using vdb = vector; using vpll = vector; using vpsl = vector; using vi = vector; using vvi = vector; using vvvi = vector; using vvvvi = vector; using vll = vector; using vvll = vector; using vvvll = vector; using vvvvll = vector; using vvvvvll = vector; #define all(A) A.begin(),A.end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rrep(i,a,b) for(int i=(ll)(a);i<=(ll)(b);i++) int main() { ll L,R,C; cin>>L>>R>>C; ll ans=2e18; rrep(i,L,min((ll)L+1000,R)){ ans=min(ans,1000*((C*i+999)/1000)-C*i); } cout << ans << endl; return 0; }