import java.util.Scanner; public class No378 { public static void main(String[] args) { Scanner s = new Scanner(System.in); long n = s.nextLong(); long n_max = n * 2; long nx = 0; while (n > 0) { nx += n; if ((n % 2) == 1) n--; n /= 2; } System.out.println(n_max - nx); } }