import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(), s, tmp; tmp = n; s = n; while (tmp > 0) { s += tmp / 2; tmp /= 2; } System.out.println(n * 2 - s); } }