#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int res = 0;     bool no = 0;     int i = 0;     while (1) {       i += m;       if (i > n) {         no = 1;         break;       }       if ((2 * i) >= n) {         res = i;         break;       }     }     if (no)       cout <<  -1  << endl;     else       cout << res;   }   