import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long N = scan.nextLong(); scan.close(); int k = (int) (Math.log10(N) / Math.log10(2)); long sum = N; for(int i = 0; i < k; i++) { long a = (long) Math.pow(2, (i + 1)); sum += (long) (N / a); } long ans = N + ((long) (N / 2)) * 2 - sum; System.out.println(ans); } }