a = int(input()) tmp = a-1 cnt = 1 while(tmp>0): tmp//=2 cnt+=1 ans = cnt*2 tmp = a-1 cnt = 1 while(tmp>0): tmp//=3 cnt+=1 ans = min(ans, cnt*3) print(ans)