import java.util.Scanner; public class TGMain { public static void main(String[] args){ int N; int ans = 0; Scanner sc = new Scanner(System.in); N = sc.nextInt(); ans = N; int k = 0; while(N != 0){ k += N; N /= 2; } System.out.println(ans*2 - k); } }