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