using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m) = (c[0], c[1]); var rest = n; var ans = 0L; var cur = m; while (cur > 1) { --rest; ans += cur; cur = (cur + 1) / 2; } if (rest > 0) { WriteLine(ans + rest); } else { WriteLine((1 << n) - 1); } } }