/**
 *  To compute the n-th power of 2. 
 *  Usage: java Alg1 <n>
 *    
 */

public class Alg1 {
    public static int count = 0;
    public static double power2 (int n) {
	count++;
	if (n == 0) return 1;
	int m = n >> 1;	 // m = floor (n / 2);
	double p = power2(m);
	p = p * p;
	if (n % 2 == 1) // n is odd
	    return 2 * p;
	else 	   // n is even;
	    return p;
    }

    public static void main(String[] args) {
	int n = Integer.parseInt(args[0]);
	System.out.println("2^" + n + " = " + power2(n));
	System.out.println("Number of times power2 was called = " + count);
    }
}
