#include using namespace std; #define int long long signed main(){ int l,r,x; cin>>l>>r>>x; r = min(r,l+10000); int ans = 1e18; for(int i=l;i<=r;i++) ans = min(ans,1000-(x*i)%1000-1000*((x*i)%1000 == 0)); cout<