import math A = int(input()) if A<=6: print(A) else: v = int(math.log(A, 2)) w = int(math.log(A, 3)) for v in range(v, v+10000): if 2**v>=A: ans = 2*v break for w in range(w, w+10000): if 3**w>=A: ans = min(ans, 3*w) break print(ans)