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