#include <cstdio>

long long N,A;
int overN(long long x,long long y) {
	if(N/x+1<y) return 1;
	if(x*y<1) printf("err");
	if(N<x*y) return 1;
	return 0;
}
long long eval(int k,long long wsum) {
	long long prod=1;
	for(int i=0;i<k;i++) {
		if(i<wsum%k) {
			if(overN(prod,wsum/k+1)) return wsum+A*k+1;
			prod*=wsum/k+1;
		} else {
			if(overN(prod,wsum/k)) return wsum+A*k+1;
			prod*=wsum/k;
		}
		if(prod<1) printf("err");
		if(prod>=N) return wsum+A*k+1;
	}
	if(N%prod) {
		return wsum+A*k+N/prod+1;
	} else {
		return wsum+A*k+N/prod;
	}
}
int main() {
	scanf("%lld%lld",&N,&A);
	long long sol=N;
	int k=1;
	long long minv=2;
	while(1) {
		if(minv>=N) {
			long long temp=(A+2)*k+1;
			if(sol>temp) sol=temp;
			break;
		}
		long long search_minv=k*2;
		long long search_maxv=N;
		while(search_minv+100000<search_maxv) {
			long long search_hav=(search_minv*2+search_maxv)/3;
			long long search_hbv=(search_minv+search_maxv*2)/3;
			long long eval_ha=eval(k,search_hav);
			long long eval_hb=eval(k,search_hbv);
			if(eval_ha>eval_hb) {
				search_minv=search_hav;
			} else {
				search_maxv=search_hbv;
			}
		}
		for(long long i=search_minv;i<=search_maxv;i++) {
			long long temp=eval(k,i);
			if(sol>temp) sol=temp;
		}
		k++;
		minv*=2;
	}
	printf("%lld\n",sol);
	return 0;
}
