import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ BigInteger n=sc.nextBigInteger(); BigInteger sum=n.divide(BigInteger.valueOf(2)); BigInteger max=n.max(n); n=n.divide(BigInteger.valueOf(2)); while(n.compareTo(BigInteger.ZERO)==1){ n=n.divide(BigInteger.valueOf(2)); sum=sum.add(n); } System.out.println(max.subtract(sum).toString()); } } }