l,r,x=map(int,input().split())
cha=x-(l%x)
if l+cha>r:
    print(-1)
else:
    print(l+cha)

不需要枚举