import java.util.Deque;
import java.util.LinkedList;
import java.util.NoSuchElementException;


public class abc {

	
	private void solveRecursive(int i, int n) {
		if(i >= n)
		{
			//Anchor -> No Objects left in Array
			return;
		} else
		{
			//Solve without the actual object
			solveRecursive(i+1,n);
			solveRecursive(i+1,n);
		}
	}
	
	public void solveIterative(int n) {
		
		// A stack to use with the algorithm
		Deque<Integer> stack = new LinkedList<Integer>();

		// The current position in the array of objects
		int i = 0;
		int count = 0;
		
		//Do till done
		while(true)
		{
			count++;
			//Still objects in array?
			if(i < n)
			{	
				//Put current Index to stack to allow backtracking
				stack.push(i);
				    
				i++; //Move to next Object
			} else
			{
				try
				{
					//get index of backtracking element from stack
					int obj = stack.pop(); //throws when empty
					
					//start search with objects excluding the obj from the stack
					i = obj +1;
					
				//Catch exception when stack is empty
				} catch(NoSuchElementException e1)
				{
					//All cases covered
					System.out.println(count);
					return;
				}
			}
			
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int n = 5;
		
		abc a = new abc();
		a.solveRecursive(0,n);
		a.solveIterative(n);

	}

}
