PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000183. Tăng và sao chép (Increase and Copy)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tăng và sao chép (Increase and Copy)

Increase and Copy

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Initially, the array contains a single element 11. In one operation you may either increment one existing element by 11, or append a copy of the value of one existing element to the end of the array. Operations may be performed in any order. Your goal is to make the sum of the array at least nn using as few operations as possible.

Input

The only line contains the integer nn, the minimum required array sum.

Output

Print one integer: the minimum number of operations required to reach total sum at least nn.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30.
  • Subtask 2 (30 points): 1≤n≤1000001\le n\le 100000.
  • Subtask 3 (50 points): 1≤n≤10000000001\le n\le 1000000000.

Examples

Example 1

Input

42

Output

11

Explanation

Start with [1][1]. Increment its only element six times to get [7][7] (six operations), then append five copies of 77. The final six entries sum to 4242 (five more operations). This uses 1111 operations, and balancing increments with copies cannot improve on it.

Example 2

Input

1

Output

0

Explanation

The initial array already sums to 11, which meets the target n=1n=1, so no operations are necessary.