program cookies
  implicit none
  integer(8), parameter :: kmax = 50_8
  integer(8) :: n, a, k, ans, s, t, m, tmp
  read(*,*) n, a
  ans = n
  do k = 2_8, kmax
    s = 1_8
    do
      t = n
      m = 0_8
      do while (t > 0_8)
        t = t/(s+1_8)
        m = m+1_8
      end do
      if (m <= k) exit
      s = s+1_8
    end do
    t = s**k
    m = 0_8
    do while (t < n)
      t = (t/s)*(s+1_8)
      m = m+1_8
    end do
    tmp = (k-1_8)*a+(k-m)*s+m*(s+1_8)
    ans = min(ans,tmp)
  end do
  write(*,'(i0)') ans
end program cookies