N = int(input()) t = n = N while N > 0: N = N // 2 t += N print(n * 2 - t)