unittest
{
	assert( [ "8" ].parse.expand.solve == 5 );
	assert( [ "7" ].parse.expand.solve == 18 );
	assert( [ "54" ].parse.expand.solve == 114 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( long );
	return tuple( s );
}

auto solve( long s )
{
	auto as = [ s ];
	for( auto i = 2L; true; i++ )
	{
		auto ai = f( as[ $ - 1 ] );
		foreach( a; as )
		{
			if( ai == a ) return i;
		}
		as ~= ai;
	}
	
	assert( false );
}

auto f( long n )
{
	if( n % 2 == 0 ) return n / 2;
	else             return 3 * n + 1;
}
