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 fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    long N, A;
    readf("%d %d\n", &N, &A);

    (log2(N).to!int+1).iota.map!((k) {
        
        long m = (long l, long r){
            while(r-l > 1) {
                long m = (l+r)/2;
                if (m^^(k+1) >= N) {
                    r = m;
                } else {
                    l = m;
                }
            }
            return r;
        }(0, (N^^(1.0/(k+1))).to!long + 1);

        return (k+1).iota.filter!(i =>
            (m-1)^^i * m^^(k+1-i) >= N
        ).map!(i =>
            A*k + i*(m-1) + (k+1-i)*m
        ).fold!min;
        
    }).fold!min.writeln;
}
