#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long>;
using vld = vector<long double>;
const long long INF = 1e9 + 5;
const long long MOD = 1e5 + 5;
const long long ASO = 1e18 + 5;
const long long ANI = 1e6 + 5;
const long long infs = -1e9;
const long long mod = -1e5;
const long long aso = -1e18;
long long t;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  for (int i = k - 1; i >= 0; --i) {
    if (n % i == 0) {
      cout << n / i * k + i;
      return 0;
    }
  }
  return 0;
}
