l,r,x = map(int,input().split()) temp = x while 1: if l<=temp<=r: print(temp) break elif temp > r: print(-1) break temp += x