#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int result, ret;
  for (int i = k - 1; i >= 1; i--) {
    int mod = n / i;
    mod = mod * k;
    mod = mod + i;
    ret = (mod / k) * (mod % k);
    if (ret == n) {
      result = mod;
      break;
    }
  }
  cout << result;
}
