#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
long long n;
cin>>n;
long long ma = n;
for(int i = 1;i<=n;i++)
{
long long x = i;
while(x!=1)
{
if(x%2==0) x=x/2;
else x= x*3+1;
ma = max(ma,x);
}
}
cout<<ma;
}