inlineintgetint(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -1; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
inlinevoidputint(int x, bool returnValue){ if (x < 0) { x = -x; putchar('-'); } if (x >= 10) putint(x / 10, false); putchar(x % 10 + '0'); if (returnValue) putchar('\n'); }
intmain(int argc, char *const argv[]){ longlongint n, now = 1l; cin >> n; while (true) { now *= 3; if (n % now) { cout << n / now + 1 << endl; return0; } } return0; }