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