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