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