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