#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, res;
  cin >> n;
  while (1) {
    if (n % 3 != 0) {
      res = (n / 3) + 1;
      break;
    }
    n = n / 3;
  }
  cout << res;
  return 0;
}
