#include using namespace std; using ll =long long; #define all(v) v.begin(),v.end() #define rep(i,a,b) for(int i=a;i=b;i--) int main() { ll L,R,C;cin>>L>>R>>C; if(R-L<=1000) { ll ans=1000; for(ll j=L;j<=R;j++) { ll k=C*j%1000; if(k!=0) k=1000-k; ans=min(ans,k); } cout<