CF507C Guess Your Way Out!
Description
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height $ h $ . The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.
Let's index all the leaf nodes from the left to the right from 1 to $ 2^{h} $ . The exit is located at some node $ n $ where $ 1
Input Format
Input consists of two integers $ h,n $ ( $ 1
Output Format
Output a single integer representing the number of nodes (excluding the exit node) Amr is going to visit before reaching the exit by following this algorithm.
Explanation/Hint
A perfect binary tree of height $ h $ is a binary tree consisting of $ h+1 $ levels. Level $ 0 $ consists of a single node called root, level $ h $ consists of $ 2^{h} $ nodes called leaves. Each node that is not a leaf has exactly two children, left and right one.
Following picture illustrates the sample test number $ 3 $ . Nodes are labeled according to the order of visit.
