http://codeforces.com/contest/334/problem/C
1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 7 long long n; 8 int main() 9 { 10 cin>>n; 11 while(n%3==0) 12 { 13 n/=3; 14 } 15 cout<<n/3+1<<endl; 16 return 0; 17 }