#include using namespace std; int main() { int L,R,C; cin>>L>>R>>C; int ans=1e9; for(int i=L;i<=R&&i-L<=10000;i++) { ans=min((long)ans,(1000-(long)i*C%1000)%1000); } cout<