($n,$m)=glob<>; if($n>=32||2**($n-1)>=$m){ while($m!=1){ $s+=$m; $m=$m+1>>1; --$n; } $s+=$n; }else{ $s=2**$n-1; } print$s;