import java.util.Scanner; public class TGMain { public static void main(String[] args){ long N; long ans = 0; Scanner sc = new Scanner(System.in); N = sc.nextLong(); while(N != 0){ ans += N; N /= 2; } System.out.println(N*2 - ans); } }