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