import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long k = n; long meisei = 0; //通常時 while(k!=0) { meisei += k; k /= 2; } System.out.println(n*2-meisei); } }