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