l,r,c = map(int,input().split()) ans = 1000 for x in range(l,min(l+1000,r+1)): ans = min(ans,1000*-(-x*c//1000)-x*c) print(ans)