#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n <= k) {
    if (n == k)
      cout << ((n * k) + 1);
    else
      cout << n + k;
  } else {
    int p = k - 1, l = 0;
    while (n % p != 0) p--;
    l = (n / p) * k + p;
    cout << l;
  }
}
