cho.sh
Notes
Loading...

Golomb Sequence

Time limit

2s

Memory limit

128 MB

Problem

The Golomb sequence is a nondecreasing sequence of positive integers with the following property: for every positive integer k, the number k appears exactly f(k) times in the sequence. In other words, as k increases, f(k) never decreases, and both k and f(k) are positive integers.

This condition determines the sequence uniquely.

Given n, compute f(n).

Input

The first line contains n.

Output

Print f(n) on the first line.

Constraints

  • 1 <= n <= 2,000,000,000