atcoder#ARC119A. [ARC119A] 119 × 2^23 + 1

[ARC119A] 119 × 2^23 + 1

Score: 300300 points

Problem Statement

In problems on AtCoder, you are often asked to:

find the answer modulo 998244353998244353.

Here, we have 998244353=119×223+1998244353 = 119 \times 2^{23} + 1. Related to this, solve the following prolem:

You are given an integer NN. Print the minimum possible value of a+b+ca + b + c for a triple of non-negative integers (a,b,c)(a, b, c) satisfying N=a×2b+cN = a \times 2^b + c.

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • NN is an integer.

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer.

998244353
143

We have 998244353=119×223+1998244353 = 119 \times 2^{23} + 1, in other words, the triple (a,b,c)=(119,23,1)(a, b, c) = (119, 23, 1) satisfies N=a×2b+cN = a \times 2^{b} + c. The value a+b+ca+b+c for this triple is 143143. There is no such triple where a+b+c142a+b+c \leq 142, so 143143 is the correct output.

1000000007
49483

We have 1000000007=30517×215+189511000000007 = 30517 \times 2^{15} + 18951, in other words, the triple (a,b,c)=(30517,15,18951)(a, b, c) = (30517, 15, 18951) satisfies N=a×2b+cN = a \times 2^{b} + c. The value a+b+ca+b+c for this triple is 4948349483. There is no such triple where a+b+c49482a+b+c \leq 49482, so 4948349483 is the correct output.

1
1

Note that we have 20=12^0 = 1.

998984374864432412
2003450165