n = int(input()) c = v = 0 for i in range(99): v = max(c+2*n,v) c += n n //= 2 print(v-c)