import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
{
Scanner in
= new Scanner
(System.
in); int n = in.nextInt();
int k = 0;
while(n > 0) {
k += n%3 + 1;
n /= 3;
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyIChTeXN0ZW0uaW4pOwoJCWludCBuID0gaW4ubmV4dEludCgpOwoJCWludCBrID0gMDsKCQl3aGlsZShuID4gMCkgewoJCQlrICs9IG4lMyArIDE7CgkJCW4gLz0gMzsKCQl9CgkJU3lzdGVtLm91dC5wcmludChrIC0gMik7Cgl9Cn0=