import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long n = Integer.parseInt(br.readLine()); long k = n; long meisei = 0; while(k!=0) { meisei += k; k /= 2; } System.out.println(n*2-meisei); } }