#include <iostream>
using namespace std;

int main() {
    int a, b, x;
    while (cin >> a >> b>> x) { // 注意 while 处理多个 case
        for(int i = a; i<= b; i++){
            if(i%x ==0){
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }
}