import sys l,r,x = map(int, input().split()) for i in range(l, r + 1): if i % x == 0: print(i) break elif i % x != 0 and i == r: print(-1)