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