l,r,x=map(int,input().split())
s=[i for i in range(l,r+1)]
found=False
for j in s:
    if int(j)%x==0:
        print(j)
        found=True
        break
if not found:
    print(-1)