#include <bits/stdc++.h>
using namespace std;
int main() {
  if (0) {
    freopen("project1.inp", "r", stdin);
    freopen("project1.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = k - 1; i > 0; --i) {
    if (n % i == 0) {
      cout << ((n / i) * k + i) << '\n';
      break;
    }
  }
  return 0;
}
