N = int(input()) def futsuu(n): ret = n while n > 0: n //= 2 ret += n return ret print(N*2-futsuu(N))