import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

int N, A;
int INF = int.max;
void main() {
  readf("%d %d\n", &N, &A);
  if (N>1000000) return;

  int[] ary = (N*2).iota.array;

  foreach(i; 2..N+1) {
    int a = ary[i]+A;
    foreach(j; 0..N/i+2) {
      int l = j*i;
      int k = a+j;
      ary[l] = min(ary[l], k);
      if (l >= N) break;
    }
  }
  ary[N..$].reduce!min.writeln;
}
