Under construction

Still being built. Things may change

Mood Balance

Time limit1sMemory limit1024 MB

Summary
Choose which minutes of an n-minute walk get negative thoughts so that the mood starts and ends at 0, using as few negative thoughts as possible.
Level

Medium7 of 10

Topics
Math, Greedy, Implementation
Solved
No attempts yet

Statement

Autumn is a season of changing moods. Some people mourn the summer that is leaving, some are glad that winter is slowly arriving, and others simply stroll and enjoy the freshness and coolness of autumn.

When Kostya walks along an autumn avenue, deep thoughts about the meaning of life often come to him. Every minute a new thought comes to him, and Kostya chooses whether it is a negative thought or an ambiguous one. There are no positive thoughts.

If Kostya's current mood is xx and it is minute ii of the walk, then:

  • a negative thought lowers his mood by 11, making it x−1x - 1;
  • an ambiguous thought first changes his mood by i−2i - 2, then doubles it, making it 2(x+i−2)2(x + i - 2).

Kostya likes calm, so he wants his mood at the end of the walk to be 00, the same as before the walk started. He is also not fond of negative thoughts, so he wants to plan the walk with as few of them as possible.

Help Kostya plan his thoughts so that his mood is 00 at the end of the walk, with as few negative thoughts as possible. His initial mood is x=0x = 0, and the minutes of the walk are numbered from 11 to nn.

Input

The only line contains one integer nn, the duration of the walk in minutes (4≤n≤10184 \leq n \leq 10^{18}).

Output

In the first line, print the minimum number of negative thoughts kk.

In the second line, print kk integers from 11 to nn in increasing order, separated by spaces. These are the minutes in which Kostya should choose negative thoughts.

Examples2

  1. Example 1

    Input
    5
    
    Expected output
    2
    1 4
    
  2. Example 2

    Input
    8
    
    Expected output
    1
    4