Problem:
 Score : 400 points    Problem Statement Caracal is fighting with 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 \lfloor X/2 \rfloor .   ( \lfloor r \rfloor 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 \leq H \leq 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.        Sample Input 1 2      Sample Output 1 3  When Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1 .  Then, Caracal can attack each of these new monsters once and win with a total of three attacks.       Sample Input 2 4      Sample Output 2 7       Sample Input 3 1000000000000      Sample Output 3 1099511627775

Solution (Python):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline









H, = map(int, input().split())

ans = 0
c = 0
while H != 0:
    H = int(H / 2)
    if c == 0:
        ans += 1
    else:
        ans += 2 ** c
    c += 1

print(ans)

Solution (Python):
H=int(input())
ans=0
p=1
while H>0:
  H//=2
  ans+=p
  p*=2
print(ans)

Solution (Python):
import sys

h = int(sys.stdin.readline().rstrip())

def main():
    x = h
    cnt = 0
    while x > 1:
        x //= 2
        cnt += 1
    res = 0
    for i in range(cnt+1):
        res += 2 ** i
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

h = I()

n = int(math.log2(h))+1

print(2**n-1)

Solution (Python):
h = int(input())

def count(x):
    if x == 1:
        return 1
    else:
        return 2 * count(x // 2) + 1

print(count(h))

Solution (Python):
h = int(input())

h = bin(h)

ans = 0
ind = 1
for i in range(len(h)-2):
    ans += ind
    ind *= 2

print(ans)

Solution (Python):
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]

import math
def main():
    H = int(input())
    R = int(math.log2(H)) + 1
    print(2 ** R - 1)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

H = int(input())

x = int(np.log2(H))+1
print(2**x-1)

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

h = int(input())

count = 0
while h > 1:
    count += 1
    h = h // 2

ans = 1
for i in range(count):
    ans = (ans*2)+1

print(ans)

Solution (Python):

H = int(input())

tmp = 1
h = H//1
ans = 0
while h>0:
    h //= 2
    ans += tmp
    tmp *= 2

print(ans)

Solution (Python):
def f(n):
    if n==1: return 1
    else: return f(n//2)*2+1

h=int(input())
print(f(h))

Solution (Python):
N = int(input())
ans = 1
c = 1
while N > 1:
    ans += 2**c
    N = N//2
    c += 1
print(ans)

Solution (Python):
H=int(input())
ans=0
Num=1
for i in range(100):
    if H==0:
        break
    else:
        ans+=Num
        H//=2
        Num*=2
print(ans)

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    H = int(input())

    n = 1
    while H > 1:
        H //= 2
        n += 1
    print(2**n-1)

if __name__ == "__main__":
    resolve()

Solution (Python):
from math import floor, log2
H = int(input())
l2 = int(log2(H))
print(2**(l2 + 1) - 1)

Solution (Python):
h = int(input())

count = 0
while h != 0:
    h //= 2
    count += 1

ans = 2 ** count - 1
print(ans)

Solution (Python):

MOD = 10 ** 9 + 7

import math

import itertools



import copy


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default



def main():
    h=int(input())
    count=0
    while True:
        if h==1:
            count+=1
            break
        else:
            h//=2
            count+=1

    print(2**count-1)

if __name__ == "__main__":
    main()

Solution (Python):
H = int(input())
output = 0
t = 1
while H>0:
    output += t
    H = int(H/2)
    t *= 2
print(output)

Solution (Python):
h = int(input())
ans = 0
t = 1
while h>0:
    ans += t
    h = h//2
    t *=2
print(ans)

Solution (Python):
h = int(input())
cnt = 0
sum_atk = 0
while h > 0:
    
    h//=2
    sum_atk+=(2**cnt)
    cnt+=1
print(sum_atk)

Solution (Python):
from math import floor
import sys
sys.setrecursionlimit(20000000)

h = int(input())

def f(n):
    if n == 1:
        return 1
    else:
        return f(floor(n/2)) * 2 + 1

print(f(h))

Solution (Python):
h = int(input())
ans = 0
while h > 0:
	ans += 1
	h = h//2
print(2**ans-1)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H):
    ans = 0
    c = 1
    h = H
    while h > 0:
        h //= 2
        ans += c
        c *= 2
    return ans


def main():
    H = read_int()
    print(slv(H))


if __name__ == '__main__':
    main()

Solution (Python):
a = int(input())
if(a==0): print("0")
else:
    b = 1
    while(b<=a):
        b=b*2
    print(b-1)

Solution (Python):
h=int(input())

cnt=0
while h!=1:
 cnt+=1
 h//=2
print(2**(cnt+1)-1)

Solution (Python):
import sys
input=sys.stdin.readline
h=int(input())
cycle=0
ans=0
while True:
    if h==1:
        ans+=2**cycle
        break
    ans+=2**cycle
    h=h//2
    cycle+=1
print(ans)

Solution (Python):
def solve(H, i=0):
    if H == 1:
        return i
    else:
        return solve(H // 2, i + 1)


def inpl():
    return list(map(int, input().split()))


H = int(input())

print(2**(solve(H) + 1) - 1)

Solution (Python):
H = int(input())

def f(n):
    if n <= 1:
        return n
    return 2*f(n//2)+1

print(f(H))

Solution (Python):
h = int(input())
ans = 1
while True:
  if h <= ans:
    print(ans)
    break
  ans = 2 * ans + 1

Solution (Python):
print(2**len(format(int(input()), 'b'))-1)

Solution (Python):
from math import floor
h = int(input())
cnt = 0
ans = 0
while h > 0:
    h >>= 1
    ans += 2**cnt
    cnt += 1
print(ans)

Solution (Python):
n = int(input())
count = 0
i = 0
while True:
    n //= 2
    count += 2**i
    i += 1

    if n == 0:
        print(count)
        exit()

Solution (Python):

def dec_monstor(hp):
    if(hp <= 1):
        return 1
    else:
        return (dec_monstor(hp // 2) * 2 + 1)

h = int(input())

print(dec_monstor(h))

Solution (Python):
h=int(input())
monster=1
count=0

while h!=0:
    count+=monster
    monster*=2
    h=h//2

print(count)

Solution (Python):
import math

h=int(input())

now = h
count = 0
attack = 0

while(now > 0):
    now = now//2
    attack += 2**count
    count += 1

print(attack)

Solution (Python):
H = int(input())
pow2 = 1
while pow2*2 <= H:
    pow2 *= 2
print(pow2*2-1)

Solution (Python):
h=int(input())
hp=h
ko=1
atk=0
while hp>0:
    hp=hp//2
    atk+=ko
    ko=ko*2

print(atk)

Solution (Python):
H = int(input())

memo = dict()

def f(n):
    if memo.get(n) is not None:
        return memo[n]
    if n == 1:
        return 1
    val = 1 + 2 * f(n // 2)
    memo[n] = val
    return val

print(f(H))

Solution (Python):
h=int(input())
mos=1
ans=0
while h>0:
    ans+=mos
    h=h//2
    mos*=2
print(ans)

Solution (Python):
h = int(input())

cnt = 0
mons = 1
while h > 1:
    h = h // 2
    cnt += mons
    mons = mons * 2

print(cnt + mons)

Solution (Python):
h = int(input())
ans = 0
count = 0
while h > 1:
    h //= 2
    ans += 2**count
    count+=1
print(ans+2**count)

Solution (Python):
H = int(input())
s = 0
i = 1
while H != 0:
    s += i
    i *= 2
    H = H//2
if i==0:
    print(0)
elif i== 1:
    print(1)
else:
    print(s)

Solution (Python):
H = int(input())

def f(h):
  if h == 1:
    return 1
  return 2 * f(h // 2) + 1
print(f(H))

Solution (Python):
H = int(input())
n = H.bit_length()
ans = 0
for i in range(n):
    ans += 2**i
print(ans)

Solution (Python):

h=int(input())
cnt=1
ans=0
while h>1:
    h//=2
    ans+=cnt
    cnt*=2
print(ans+cnt)

Solution (Python):
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from fractions import gcd
e = enumerate

sys.setrecursionlimit(10**7)
H = int(input())

cnt = 1
phase = 1
while H>1:
    H //= 2
    cnt += phase * 2
    phase *= 2

print(cnt)

Solution (Python):
h=int(input())
hh=len(bin(h))-2
print(pow(2,hh)-1)

Solution (Python):
H = int(input().strip())

def solve(n):
  return 1+solve(n//2)*2 if n > 1 else 1

print(solve(H))

Solution (Python):

import sys
input = sys.stdin.readline

h = int(input())
cnt = 0
while h > 0:
    h //= 2
    cnt += 1
print(2**cnt - 1)

Solution (Python):
H = int(input())

ans = 0
k = 0

while H > 1:
    ans += 2 **k
    k += 1
    H //= 2

print(ans+2**(k))

Solution (Python):
h=int(input())
buf=h
count=0
for i in range(1000):
    if buf==1:
        count+=1
        break
    buf=buf//2
    count+=1
print(2**count-1)

Solution (Python):
H = int(input())
i = 0
while H > 0:
    H //= 2
    i += 1
print(2**i - 1)

Solution (Python):
H = int(input())

ans = 0
mul = 1
while H >= 1:
    ans += mul
    mul *= 2
    H //= 2

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
H = int(input())
cnt = 0
while True:
    H //= 2
    cnt += 1
    if H == 0:
        break
ans = [1]
for i in range(cnt - 1):
    ans.append(ans[-1] * 2)
print(sum(ans))

Solution (Python):




def main():
    H = int(input())

    i = 0
    count = 0
    h = H

    while h > 0:
        h = h // 2
        count += 2**i
        i += 1

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

H = int(input())

ans = 1
hoge = 1
H //= 2
while H > 0:
    hoge *= 2
    H //= 2
    ans += hoge

print(ans)

Solution (Python):
h = int(input())

turn = 0
attacks = 0
while h > 0:
    h //= 2
    attacks += 2 ** turn
    turn += 1

print(attacks)

Solution (Python):
H = int(input())
n = len(bin(H))-2 
print(2**n-1)

Solution (Python):
import math

h = int(input())
cnt = 0
while(h!=1):
    h = math.floor(h/2)
    cnt += 1
cnt+=1
print(2**cnt-1)

Solution (Python):
h = int(input())

n=1
while 1:
    if h==1:
        break
    h//=2
    n+=1

print(2**n-1)

Solution (Python):
print((1<<(int(input()).bit_length()))-1)

Solution (Python):
H = int(input())
ans = 0
n = 1
while H:
    ans+=n
    H//=2
    n*=2
print(ans)

Solution (Python):
h = int(input())
count = 0
num = 0
while h > 0:
    count += (2 ** num)
    h //= 2
    num += 1
print(count)

Solution (Python):
h=int(input())
res=0
cur=h
n=1
while cur > 0:
    cur = cur //2
    res += n
    n*=2
print(res)

Solution (Python):
h = int(input())
ans = 0
cnt = 1
while h != 1:
    h //= 2
    ans += cnt
    cnt *= 2
else:
    ans += cnt

print(ans)

Solution (Python):

H=int(input())
ans=0
p=1
while H > 1:
    H=H//2
    ans+=p
    p=p*2

ans+=p
print(ans)

Solution (Python):
H = int(input())
for i in range(1,50):
    if H < 2**i:
        print(2**i-1)
        break

Solution (Python):
import sys
h=int(input())
ct=1
ans=0
for i in range(100):
  ans+=ct
  h=h//2
  ct*=2
  if h==0:
    print(ans)
    sys.exit()

Solution (Python):
def calc_attack(N):
    if N==1:
        return 1
    else:
        return (2*calc_attack(N//2) + 1)

H = int(input())

print(calc_attack(H))

Solution (Python):
H=int(input())
t=0
while H:
    t+=1
    H//=2
print((1<<t)-1)

Solution (Python):
def f(n):
  if n == 1: return 1
  else: return f(n//2)*2

x = int(input())
print(2*f(x)-1)

Solution (Python):
H = int(input())

def f(x):
    if x == 1:
        return 1
    return 1 + 2 * f(x //2)

print(f(H))

Solution (Python):
h = int(input())
x = h
y = 0
for i in range(h):
  x = x//2
  y += 2**i
  if x == 1:
    y += 2**(i+1)
    break
print(y)

Solution (Python):
H = int(input())
n = H.bit_length()
ans = (1<<(n))-1
print(ans)

Solution (Python):
def solve(n):
	if n==1:
		return 1
	return 1+2*solve(n//2)
n=int(input())
print(solve(n))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    h=II()
    s=h.bit_length()
    print(pow(2,s)-1)

main()

Solution (Python):
H = int(input())
def f(h):
    if h==1:
        return 1
    else:
        return 2*f(h//2)+1
print(f(H))

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

h=int(input())
ans=0
now=1
while h:
    h//=2
    ans+=now
    now*=2

print(ans)

Solution (Python):
H = int(input())

ans = 0
tmp = 1 
while H >= 1:
    ans += tmp
    tmp *= 2
    H //= 2

print (ans)

Solution (Python):
def main():
    H = int(input())
    def helper(h):
        if h == 1:
            return 1
        else:
            return 1 + helper(h // 2) * 2
    print(helper(H))
    

main()

Solution (Python):
n=int(input())
i=0
a=0
while n!=0:
    n=n//2
    a+=2**i
    i+=1
print(a)

Solution (Python):
H = int(input())
ans = 0
n = 1
while H > 0:
    H //= 2
    ans += n
    n *= 2
print(ans)

Solution (Python):


H = int(input())


cnt = 0
while H != 1:
  cnt += 1
  H //= 2

ans = 0
for i in range(cnt+1):
  ans += 2 ** i

print(ans)

Solution (Python):
h = int(input())

ans = 0
ad = 1
while h:
    h //= 2
    ans += ad
    ad *= 2

print(ans)

Solution (Python):
h = input()
n = 1
c = 0
while h:
    h //= 2
    c += n
    n *= 2
print c

Solution (Python):
n = int(input())

cnt = 1
ans = 0
while True:
    if n // 2 == 0:
        ans += cnt
        cnt *= 2
        break
    else:
        n = n // 2
    ans += cnt
    cnt *= 2
print(ans)

Solution (Python):
H = int(input())

def atk(n):
    if n==1: return 1
    return 1 + 2*(atk(n//2))
print(atk(H))

Solution (Python):
import math
H = int(input())


ans = 0
count = 1
while(H > 0):
    ans += count
    H = H // 2
    count *= 2
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10995116)


def get_func():
    cache = {1: 1}

    def f(x):
        if x in cache:
            return cache[x]
        cache[x] = f(x // 2) * 2 + 1
        return cache[x]

    return f


h = int(input())
f = get_func()
print(f(h))

Solution (Python):
A=1
H=int(input())
while H!=1:
    A+=1
    H//=2
print((1<<A)-1)

Solution (Python):
import sys
input = sys.stdin.readline
h=int(input())
num=1
ans=0
while h>0:
    h//=2
    ans+=num
    num*=2
print(ans)

Solution (Python):
from math import log2, floor
H = int(input())
a = floor(log2(H))
print(2**(a+1) - 1)

Solution (Python):
d = {}
def solve(h):
    if h in d:
        return d[h]
    if h == 1:
        return 1
    else:
        res = solve(h / 2) * 2 + 1
        d[h] = res
        return res

assert solve(2) == 3
assert solve(4) == 7
assert solve(1000000000000) == 1099511627775

h = int(raw_input())

print solve(h)

Solution (Python):



from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    h = ii()
    ans = 0
    mons = 1
    while h > 0:
        ans+=mons
        h//=2
        mons*=2
    print(ans)


main()

Solution (Python):
H = int(input())
num_m = 1
ans = 0
while True:
    if H<2:
        break
    H = H//2
    ans += num_m
    num_m *= 2
print(ans+num_m)

Solution (Python):
from functools import lru_cache

@lru_cache()
def attack(H):
    if H==0:
        return 0
    elif H==1:
        return 1
    else:
        return 2*(attack(H//2))+1

H=int(input())
print(attack(H))

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
x = 0
while N // 2 > 0:
  x += 1
  N //= 2
print(pow(2, x + 1) - 1)

Solution (Python):
h = int(input())
cnt = 0
while h > 0:
    if h == 1:
        cnt += 1
        break
    else:
        h //= 2
        cnt += 1

print(2 ** cnt - 1)

Solution (Python):

import sys
import math
INF = float("inf")


def solve(H: int):
    M = int(math.log2(H))
    print(pow(2, M+1)-1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    solve(H)


if __name__ == '__main__':
    main()

Solution (Python):
h = int(input())

ans = 0
count = 0
while h > 0:
    ans += (2 ** count)
    count += 1
    h = h//2
print(ans)

Solution (Python):
H = int(input())
print(2 ** (H.bit_length()) - 1)

Solution (Python):
def examA():
    H,A = LI()
    ans = (H-1)//A+1
    print(ans)
    return

def examB():
    H, N = LI()
    A = LI()
    if H>sum(A):
        print("No")
    else:
        print("Yes")
    return

def examC():
    N, K = LI()
    H = LI()
    H.sort()
    ans = sum(H[:max(0,N-K)])
    print(ans)
    return

def examD():
    H = I()
    ans = 2**(H.bit_length())-1
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

"""

"""

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    h = int(input())

    def attack(n):
        if n == 1:
            return 1
        return 1+2*attack(n//2)

    print(attack(h))


if __name__ == '__main__':
    main()

Solution (Python):
H = int(input())

n = 1
count = 0
while H > 0:
	count += n
	H //= 2
	n *= 2

print(count)

Solution (Python):
H = int(input())

n = H.bit_length()
print(pow(2,n)-1)

Solution (Python):
H = int(input())
i = 1
ans = 0
while H != 0:
    ans += i
    H = H//2
    i = i*2
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    H = int(input())
    ans = 0
    count = 0
    while H >= 1:
        H = H // 2
        ans += 2 ** count
        count += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
H = int(input())
cnt = 0
t = 1
while True:
    if H<=0:
        break
    H//=2
    cnt += t
    t *=2
print(cnt)

Solution (Python):
h = int(input())
ans = 0
x = 1
while h != 0:
    ans += 1*x
    h //= 2
    x *= 2

print(ans)

Solution (Python):
H = int(input())
ans = 0
enemy = 1
while H>1:
    ans += enemy
    enemy *= 2
    H //= 2
ans += enemy
print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline

    H = int(input())

    ans = 0
    k = 1
    while True:
        if H == 1:
            ans += k
            break
        else:
            ans += k
            H //= 2
            k *= 2
    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

h=int(input())
def f(n):
    if n==1:
        return 1
    return 1+f(n//2)*2
print(f(h))

Solution (Python):
H = int(input())

count = 0
h = H
while h>0:
    h//=2
    count+=1

print(2**count - 1)

Solution (Python):
from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 7)


@lru_cache(maxsize=None)
def dfs(h):
    if h == 1:
        return 1
    return 1 + dfs(h // 2) * 2


def main():
    h = int(input())
    print(dfs(h))


if __name__ == '__main__':
    main()

Solution (Python):
h = int(input())

def calc(n):
    if n == 1:
        return 1
    else:
        if n%2 == 0:
            return 1 + 2 * calc(n//2)
        else:
            return 1 + 2 * calc((n-1)//2)

print(calc(h))

Solution (Python):
from math import log2
def main():
    H = int( input())
    n = int( log2( H))
    print( pow(2, n+1)-1)
if __name__ == '__main__':
    main()

Solution (Python):
H = int(input())

res = 0
cnt = 1
while H > 0:
    res += cnt
    cnt += cnt
    H //= 2

print(res)

Solution (Python):
h=int(input())
s=1
while h>1:
    h//=2
    s+=1
print(2**s-1)

Solution (Python):
H = int(input())

now = 1
ans = 0
while H > 0:
    ans += now
    H //= 2
    now *= 2

print(ans)

Solution (Python):
H = int(input())

def rec(X):
    if X==1:
        return 1
    else:
        return 2*rec(X//2)+1
print(rec(H))

Solution (Python):


def get(n):
	if n == 1:
		return 1
	else:
		return 1 + 2 * get(n//2)

n = int(input())

print(get(n))

Solution (Python):
H=int(input())
r,x=0,1
while H>0:
    r+=x
    H//=2
    x*=2
print(r)

Solution (Python):
H = int(input())

ans = 1
t = 1
while H > 1:
  t *= 2
  ans += t
  H //= 2
  
print(ans)

Solution (Python):
H = int(input())
res = 1
while H!=1:
    H = H//2
    res += 1
print(2**res-1)

Solution (Python):
def num(a):
  if a == 1:
    return 1
  else:
    return 1+2*(num(a//2))
h = int(input())
print(num(h))

Solution (Python):
h = int(input())
n = 1
ans = 0
while h > 0:
  ans += n
  n *= 2
  h //= 2
print(ans)

Solution (Python):
h = int(input())

ans = 0
k = 1
while h:
    ans += k
    k *= 2
    h //= 2

print(ans)

Solution (Python):
H = int(input())

ans = 0
num = 1
while H >= 1:
    ans += num
    H //= 2
    num *= 2

print(ans)

Solution (Python):
h = int(input())
t = 1
ans = 0
while h > 0:
    ans += t
    t *= 2
    h //= 2
print(ans)

Solution (Python):
n=int(input())
c=0
while n!=0:
    n//=2
    c+=1
print(2**c-1)

Solution (Python):
H = int(input())
now = 1
ans = 0

while H>0:
    ans += now
    H //= 2
    now *= 2
print(ans)

Solution (Python):
H = int(input())
ans = 0
now = 1
while H > 0:
    ans += now
    now *= 2
    H //= 2

print(ans)

Solution (Python):

H = int(input())
num = 1
ans = 0

while H != 0:

    ans += num
    num *= 2
    H //= 2

print (ans)

Solution (Python):
H = int(input())
print(2 ** H.bit_length() - 1)

Solution (Python):
h = int(input())
a = 1
ans=0
while h > 0:
    ans += a
    a *= 2
    h //= 2
print(ans)

Solution (Python):
H = int(input())

cnt = 1
ret = 0
while H >= 1 :
  H //= 2
  ret += cnt
  cnt *= 2
  
print(ret)

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))



H = I()

ans = 0
for i in range(H.bit_length()):
    ans += 2**i

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

h = ri()
res = 0
count = 0
while h:
    h //= 2
    res += 2**count
    count += 1
print(res)

Solution (Python):
H = input()

ans = 0
n = 1
while H>0:
  ans += n
  H /= 2
  n *= 2
print ans

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h = I()



ret = 0
cnt = 1
while h:
    ret += cnt
    cnt *= 2
    h //= 2


print(ret)

Solution (Python):


from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

H = input()
S = 1
ans = 0
while H > 0:
    ans += S
    H /= 2
    S *= 2
print ans

Solution (Python):

import sys


def solve(H: int):
    layer = 0
    h = H
    while True:
        h //= 2
        layer += 1
        if h == 0:
            break
    answer = 0 
    for i in range(layer):
        answer += 2**i
    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    solve(H)

if __name__ == '__main__':
    main()

Solution (Python):
h=int(input())

ans = 0

while(h):
    ans *= 2
    h//=2
    ans+=1
print(ans)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h = onem()
co = 1
c = 0
while h:
    h //= 2
    c += co
    co *= 2

print(c)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

h = ni()

def dfs(h):
    if h == 1:
        return 1
    else:
        return dfs(h//2)*2 + 1

print(dfs(h))

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H=int(input())
    print(2**H.bit_length()-1)

if __name__ == '__main__':
    main()

Solution (Python):
h = int(input())
cnt = 1
ans = 0
while h:
    ans += cnt
    h//=2
    cnt *= 2
print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h = I()
    k = h.bit_length()
    print((1<<k)-1)
    return


if __name__ == "__main__":
    solve()