#include #include #include using namespace std; int main(){ long long A; cin >> A; long long cnt = 0, cnt2 = 0; long long t = A; long long temp1 = 1; long long c = 0; while(A > temp1){ temp1 *= 2; c++; if(A == temp1){ cout << c * 2 << endl; return 0; } } temp1 = 1; c = 0; while(A > temp1){ temp1 *= 3; c++; if(A == temp1){ cout << c * 3 << endl; return 0; } } while(t > 0){ t /= 2; cnt++; } long long t1 = cnt * 2; while(A > 0){ A /= 3; cnt2++; } long long t2 = cnt2 * 3; cout << min(t1, t2) << endl; }