import java.util.*; public class Test { public static void main(String[] args) { Scanner s = new Scanner(System.in); long n = s.nextLong(); long sum1 = 0; long sum2 = 0; for(long i=n;i>0;i/=2){ sum1 = sum1 + i; } sum2 = sum2 + 2 * n; System.out.println(sum2 - sum1); } }