using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var m = int.Parse(line[1]); getAns(n, m); } static void getAns(int n, int m) { var count = 0; long ans = m; while (m > 1) { m = m % 2 == 0 ? m / 2 : (m + 1) / 2; ans += m; count++; } ans += n - count - 1; Console.WriteLine(ans); } }