#include <cassert>
#include <vector>
#include <functional>
#include <unordered_map>
#include <iostream>
using namespace std;

constexpr long long INF = 1LL<<60;

long long subtask(int N, long long A) {
    vector<long long> dp(N+1, INF);
    dp[1] = 0;
    for (int i = 1; i <= N/2; i++) {
        for (int j = 2; i * j <= N; j++) {
            dp[i * j] = min(dp[i * j], dp[i] + j + A);
        }
    }
    long long ans = INF;
    for (int i = 1; i <= N; i++)
        ans = min(ans, dp[i] + (N - 1) / i + 1);
    return ans;
}

int main() {
    long long N, A; cin >> N >> A;
    long long ans = N;
    for (long long i = 2; i * i <= N; i++) {
        ans = min(ans, A + i + 1 + (N - 1) / i);
    }
    for (int t = 2; 1LL << t <= N; t++) {
        int k = 2 * t, s = 2, a = t, b = 0;
        long long d = 1LL << t;
        while (d <= N) {
            ans = min(ans, A * t + k + 1 + (N - 1) / d);
            k++;
            d = d / s * (s + 1);
            if (a == 1) { s++; a = t; b = 0; }
            else { a--; b++; }
        }
    }
    cout << ans << endl;
    if (N <= 1e7)
        cerr << N << " " << A << " " << (ans == subtask(N, A) ? "OK" : "WA") << endl;
}
