l 0 = (1,1)
l n = (\(a,b)->(3+a*2,1+2*b)) (l (n-1))
main=map read.words<$>getLine>>=print.f
 where f [n,x] |x==0         = 0
               |(fst(l n))<x = (snd(l n))+1+(f [n,x-(fst(l n))-1])
               |(fst(l n))>x = f [n-1,x-1]
               |otherwise    = (snd(l n))