import java.util.*; class B{ static Scanner s = new Scanner(System.in); public static void main(String[] args) { long in = Long.parseLong(s.next()),l=0,b=in; while(b>0) { l+=b; b/=2; } System.out.println(in*2-l); } }