#include using namespace std; using ll = long long; using P = pair; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() int main(){ ll n; cin >> n; ll ans = 1LL<<60; for(ll i=2;i<=ans;i++){ ll x = 1, cnt = 0; while(x<=n/i){ x *= i; cnt++; } ans = min(ans, i+cnt+n-x); } cout << ans << endl; return 0; }