#include <iostream>
using namespace std;

#define I int
#define LL long long


void Times();

int main() {
	Times();

	return 0;
}

void Times() {
	I l, r, x, t = 0;
	cin >> l >> r >> x;
	t = r / x;
	if (t * x < l) {
		cout << -1;
		return ;
	} else
		cout << x * t;
}