atcoder#ARC109B. [ARC109B] log

[ARC109B] log

Score : 400400 points

Problem Statement

Snuke is visiting a shop in Tokyo called 109 to buy some logs. He wants nn logs: one of length 11, one of length 22, ......, and one of length nn. The shop has n+1n+1 logs in stock: one of length 11, one of length 22, \dots, and one of length n+1n+1. Each of these logs is sold for 11 yen (the currency of Japan).

He can cut these logs as many times as he wants after buying them. That is, he can get kk logs of length L1,,LkL_1, \dots, L_k from a log of length LL, where L=L1++LkL = L_1 + \dots + L_k. He can also throw away unwanted logs.

Snuke wants to spend as little money as possible to get the logs he wants. Find the minimum amount of money needed to get nn logs of length 11 to nn.

Constraints

  • 1n10181 \leq n \leq 10^{18}

Input

Input is given from Standard Input in the following format:

nn

Output

Print the minimum amount of money needed to get nn logs of length 11 to nn.

4
3

One way to get the logs he wants with 33 yen is:

  • Buy logs of length 22, 44, and 55.
  • Cut the log of length 55 into two logs of length 11 each and a log of length 33.
  • Throw away one of the logs of length 11.
109109109109109109
109109108641970782