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