import java.util.*; public class Exercise97{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long nd = n; long a = 0; while(nd > 0){ a += nd; nd /= 2; } System.out.println(n * 2 - a); } }