#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> L >> R >> C; int x=1000/C; if(L<=x && x<=R) cout << 1000-C*x << endl; else if(R