#include #define int long long using namespace std; const int N=1e5+10; int n,m; signed main(){ int l,r,c; cin>>l>>r>>c; int ans=1000; for(int i=l;i<=min(r,l+1000);i++){ int now=1000-c*i%1000; ans=min(ans,now); } cout<