#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  int temp;
  for (int i = k - 1; i > 0; --i) {
    temp = n / i;
    temp *= k;
    temp += i;
    if ((temp / k) * (temp % k) == n) {
      cout << temp << "\n";
      break;
    }
  }
  return 0;
}
