import sys l, r, x = map(int, input().split()) def solve(a, b, c): for i in range(a, b + 1): if i % c == 0: return i return -1 res = solve(l, r, x) print(res)