#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int m = 1;
  int i = 1;
  while (i < k) {
    if (n % i == 0) {
      m = i;
    }
    i++;
  }
  int a = n / m;
  int output = k * a + m;
  cout << output;
}
