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