



import qiskit
from qiskit.providers import Backend





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase							):
    __a			,  __a					=							bin(_UpperCAmelCase							)[2:], bin(_UpperCAmelCase							)[2:]  # Remove leading '0b'

    # Ensure that both strings are of the same length
    if len(_UpperCAmelCase							) > len(_UpperCAmelCase							):
        __a					=							y.zfill(len(_UpperCAmelCase							)							)
    else:
        __a					=							x.zfill(len(_UpperCAmelCase							)							)

    # We need (3 * number of bits in the larger number)+1 qBits
    # The second parameter is the number of classical registers, to measure the result
    __a					=							qiskit.QuantumCircuit((len(_UpperCAmelCase							) * 3) + 1  ,					len(_UpperCAmelCase							) + 1							)

    # We are essentially "not-ing" the bits that are 1
    # Reversed because it's easier to perform ops on more significant bits
    for i in range(len(_UpperCAmelCase							)							):
        if x[::-1][i] == "1":
            circuit.x(_UpperCAmelCase							)
    for j in range(len(_UpperCAmelCase							)							):
        if y[::-1][j] == "1":
            circuit.x(len(_UpperCAmelCase							) + j							)

    return circuit, x, y





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase  ,					_UpperCAmelCase  ,					_UpperCAmelCase  ,					_UpperCAmelCase  ,					):
    circuit.ccx(_UpperCAmelCase  ,					_UpperCAmelCase  ,					_UpperCAmelCase							)
    circuit.cx(_UpperCAmelCase  ,					_UpperCAmelCase							)
    circuit.ccx(_UpperCAmelCase  ,					_UpperCAmelCase  ,					_UpperCAmelCase							)
    circuit.cx(_UpperCAmelCase  ,					_UpperCAmelCase							)
    circuit.cx(_UpperCAmelCase  ,					_UpperCAmelCase							)





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase  ,					_UpperCAmelCase = qiskit.Aer.get_backend('''aer_simulator'''							)  ,					):

    if vala < 0 or vala < 0:
        raise ValueError('''Both Integers must be positive!'''							)

    # Store the Integers
    __a			,  __a			,  __a					=							store_two_classics(_UpperCAmelCase  ,					_UpperCAmelCase							)
    for i in range(len(_UpperCAmelCase							)							):
        full_adder(_UpperCAmelCase  ,					_UpperCAmelCase  ,					len(_UpperCAmelCase							) + i  ,					len(_UpperCAmelCase							) + len(_UpperCAmelCase							) + i  ,					len(_UpperCAmelCase							) + len(_UpperCAmelCase							) + i + 1							)
        circuit.barrier()  # Optional, just for aesthetics

    # Measure the resultant qBits
    for i in range(len(_UpperCAmelCase							) + 1							):
        circuit.measure([(len(_UpperCAmelCase							) * 2) + i]  ,					[i]							)

    __a					=							qiskit.execute(_UpperCAmelCase  ,					_UpperCAmelCase  ,					shots=1							).result()

    # The result is in binary. Convert it back to int
    return int(list(res.get_counts()							)[0]  ,					2							)


if __name__ == "__main__":
 import doctest

 doctest.testmod()










from __future__ import annotations

__snake_case		:Union[str, Any] 						=	{1: 1}





def 	__snake_case      (     _UpperCAmelCase							):
    if n in COLLATZ_SEQUENCE_LENGTHS:
        return COLLATZ_SEQUENCE_LENGTHS[n]
    __a					=							n // 2 if n % 2 == 0 else 3 * n + 1
    __a					=							collatz_sequence_length(_UpperCAmelCase							) + 1
    __a					=							sequence_length
    return sequence_length





def 	__snake_case      (     _UpperCAmelCase = 1000000							):
    __a					=							max((collatz_sequence_length(_UpperCAmelCase							), i) for i in range(1  ,					_UpperCAmelCase							)							)
    return result[1]


if __name__ == "__main__":
 print(solution(int(input().strip())))





