Description
卡拉卡尔正在与一只怪物作战。
怪物的生命值为 H。
卡拉卡尔可以通过选择一个怪物进行攻击。当一个怪物受到攻击时,基于该怪物的生命值,发生以下情况:
• 如果怪物的生命值为 1,它会降为 0。
• 如果怪物的生命值 X 大于 1,则该怪物消失。然后,出现两个新怪物,每个怪物的生命值为 ⌊X/2⌋。
(⌊r⌋ 表示不超过 r 的最大整数。)
当所有现存怪物的生命值降为 0 或以下时,卡拉卡尔获胜。请找出卡拉卡尔在获胜之前所需的最小攻击次数。
Problem Statement
Caracal is fighting against a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
• If the monster's health is 1, it drops to 0.
• If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of ⌊X/2⌋⌊X/2⌋.
( ⌊r⌋ denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning.
Constraints
• 1≤H≤10^12
• All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.