#C2813. Taco Sequence

    ID: 46171 Type: Default 1000ms 256MiB

Taco Sequence

Taco Sequence

You are given an integer \(n\) (1-indexed). You need to generate the \(n\)-th number in a particular sequence defined as follows:

Start with \(a_1 = 1\). For each \(i \ge 1\), the next number \(a_{i+1}\) is determined by:

\[ a_{i+1} = \begin{cases} \frac{a_i}{2} & \text{if } a_i \text{ is even},\\[6pt] 3a_i + 1 & \text{if } a_i \text{ is odd}. \end{cases} \]

Your task is to compute \(a_n\). If \(n\) is less than 1, the program should report an error.

Example: For \(n=4\), the sequence is: \(1, 4, 2, 1, \ldots\), so the output is 1.

inputFormat

The input is provided through standard input (stdin) and consists of a single integer \(n\) (1-indexed),\(n\geq 1\).

outputFormat

Output the \(n\)-th number in the sequence to standard output (stdout).

## sample
1
1