import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); long N = Long.parseLong(reader.readLine()); System.out.println(N*2 - calculateReputation(N)); } private static long calculateReputation(long n) { long reputation = 0; while (n != 0) { reputation += n; n = n / 2; } return reputation; } }