This page is still under construction.

Parts of this page are still being built. What you see may change.

Non-consecutive Summands

Time limit1sMemory limit128 MB

Summary
Split a positive integer into the most distinct parts possible, none of which are consecutive.
Level

Medium5 of 10

Topics
Greedy, Math, Binary search
Solved
No attempts yet

Problem

You are given a positive integer nn. You want to write it as a sum of positive integers while obeying both of these rules:

  • No integer may be used more than once (each integer appears at most once).
  • No two consecutive integers may be used together (for example, 33 and 44 cannot both appear).

Subject to these rules, make the number of summands as large as possible. Find that maximum number of summands.

Input

The first and only line contains an integer nn (1≤n≤10181 \le n \le 10^{18}).

Output

Print a single integer: the maximum number of summands in such a decomposition.

Examples3

  1. Example 1

    Input
    6
    
    Expected output
    2
    
  2. Example 2

    Input
    4
    
    Expected output
    2
    
  3. Example 3

    Input
    9
    
    Expected output
    3