l, r, x = map(int, input().split())
y = l + x - l % x
print(y if y <= r else -1)