#include <bits/stdc++.h>
int main() {
  int k, x, n;
  scanf("%d %d", &n, &k);
  int p = k;
  while (p >= 1) {
    x = k * n / p + p;
    if (n == ((x / k) * (x % k))) break;
    p--;
  }
  printf("%d", x);
}
