#include <bits/stdc++.h>
using namespace std;
const long long N = 200;
const double eps = 1e-6;
const double pi = 4 * atan(1);
long long n, t;
long long mx, mn, m;
int solve() {
  cin >> n;
  long long p = 3;
  while (1) {
    long long k = n / p;
    if (n % p) {
      k++;
      printf("%lld\n", k);
      break;
    }
    p *= 3;
  }
  return 0;
}
int main() { return solve(); }
