#include <bits/stdc++.h>
using namespace std;
int main() {
  int x = 0;
  int n, k;
  scanf("%d %d", &n, &k);
  int mod = k - 1;
  for (; mod > 0 && n % mod != 0; mod--) {
  }
  printf("%d", (n / mod) * k + mod);
}
