l,r,c = map(int,input().split()) if r-l >= 1000: print(0) else: m = 1000 for i in range(l,r+1): m = min(m, (i*c)%1000) print(m)