22 lines
411 B
Python
22 lines
411 B
Python
chisloVV = int(input())
|
|
deystviy = 0
|
|
|
|
while chisloVV != 1:
|
|
if chisloVV % 3 == 0:
|
|
chisloVV = chisloVV / 3
|
|
deystviy += 1
|
|
|
|
elif (chisloVV + 1) % 3 == 0:
|
|
chisloVV = (chisloVV + 1) / 3
|
|
deystviy += 2
|
|
|
|
elif (chisloVV - 1) % 3 == 0:
|
|
chisloVV = (chisloVV - 1) / 3
|
|
deystviy += 2
|
|
|
|
else:
|
|
chisloVV = chisloVV - 1
|
|
deystviy += 1
|
|
|
|
print(deystviy)
|