Under construction

Still being built. Things may change

Level Hamburger

Time limit0.5sMemory limit512 MB

Summary
A level-N burger is defined recursively from buns and patties; count how many patties lie in the bottom X layers.
Level

Medium5 of 10

Topics
Recursion, Divide and conquer, Math, Implementation
Solved
No attempts yet

Problem

Sanggeun Nald has released a new hamburger, the level-L burger. A level-L burger is made as follows.

  • A level-0 burger consists of a single patty.
  • A level-L burger consists of a bun, a level-(L-1) burger, a patty, a level-(L-1) burger, and a bun, in that order. (L ≥ 1)

For example, a level-1 burger looks like 'BPPPB' and a level-2 burger looks like 'BBPPPBPBPPPBB'. (B is a bun, P is a patty.)

Sangdo visits Sanggeun Nald and orders a level-N burger. If Sangdo eats the bottom X layers of the hamburger, how many patties does he eat? One layer is one bun or one patty.

Input

The first line gives N and X.

Output

Print the number of patties Sangdo eats on the first line.

Constraints

  • 1 ≤ N ≤ 50
  • 1 ≤ X ≤ the number of layers in a level-N burger

Examples3

  1. Example 1

    Input
    2 7
    
    Expected output
    4
    
  2. Example 2

    Input
    1 1
    
    Expected output
    0
    
  3. Example 3

    Input
    50 4321098765432109
    
    Expected output
    2160549382716056