#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  if (n < k)
    cout << "-1"
         << "\n";
  else
    cout << (n + 2 * k - 1) / 2 / k * k << "\n";
  return 0;
}
