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