import sys

a,b,c=input().split()
for i in range(int(a),int(b)+1):
    if i%int(c)==0:
        print(i)
        break
else:
    print(-1)