For this Question: Sara has N numbers (from 1 to N), she wishes to make all the numbers equal. For a number X, she can either unset any set bit or set any unset bit in the binary representation of X in exchange for 1 coin. 
Sara wants to know the minimum number of coins to make all the numbers equal help her to find it.Input contains a single line containing the value of N.

<b>Constraints:- </b>
1 <= N <= 10<sup>12</sup>Print a single integer containing minimum coinsSample Input:-
4

Sample Output:-
5

Explanation:-
1 = 001 = 011 = 1 coin
2 = 010 = 011 = 1 coin
3 = 011 = 011 = 0 coin
4 = 100 = 011 = 3 coin
Total = 5

Sample Input:-
2

Sample Output:-
2, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) {
         Scanner sc = new Scanner(System.in);
         long n = sc.nextLong();
         n++;
         long ans =0;

         for(long i=0; i<=45 ; i++){

             if(n <= (1L << i)){
                 break;
             }

             long x = (n/(1L <<i));
             long ones = (x >> 1L) * (1L<<i);

             long a = ones + (x%2 !=0 ? (n%(1L<<i)) : 0);
             ans = ans + Math.min( n-1-a, a);
         }
         System.out.println(ans);
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?