l,r,x = map(int, input().split())
for y in range(l,r+1):
    if y%x == 0:
        print(y)
        break
else:
    print(-1)