{"raw_statement":[{"iden":"statement","content":"Little Liesbeth likes to play with strings. Initially she got a string of length n, consisting of letters '_a_' only. \n\nThen Liesbeth performs next operations with the string:\n\nLiesbeth stops when she has the string of length 1. For example, if n = 4, she needs 6 operations : \n\nLiesbeth found that for some n number of operations is too big, and its hard to understand if the process is finite. So she asked You to write the program to help her.\n\nFirst line of the input contains one integer n (2 ≤ n ≤ 106) — length of the initial string.\n\nPrint one integer — number of operations needed to obtain string of length 1. If process is infinite, print  - 1 instead.\n\n"},{"iden":"input","content":"First line of the input contains one integer n (2 ≤ n ≤ 106) — length of the initial string."},{"iden":"output","content":"Print one integer — number of operations needed to obtain string of length 1. If process is infinite, print  - 1 instead."},{"iden":"examples","content":"Input4Output6Input3Output24"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the initial length of the string, with $ 2 \\leq n \\leq 10^6 $.  \nLet $ f(n) $ denote the number of operations required to reduce the string to length 1, where each operation replaces the string of length $ k \\geq 2 $ with a new string of length $ \\left\\lfloor \\frac{k}{2} \\right\\rfloor $.\n\n**Constraints**  \n$ 2 \\leq n \\leq 10^6 $\n\n**Objective**  \nCompute $ f(n) $, defined recursively by:  \n$$\nf(1) = 0, \\quad f(k) = 1 + f\\left(\\left\\lfloor \\frac{k}{2} \\right\\rfloor\\right) \\quad \\text{for } k \\geq 2\n$$  \nIf the process is infinite, output $ -1 $.","simple_statement":"Given a string of n 'a's, repeatedly replace any two adjacent 'a's with one 'b'. Stop when the string has length 1. If impossible, return -1. Output the number of operations needed.","has_page_source":false}