using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); this.itemCount = inpt[0]; int start = inpt[1]; int flag = (1 << start); long ans = this.GetAns(start, flag, false); Console.WriteLine(ans); } private int itemCount; private long GetAns(int num, int flag, bool useDesc) { int max = (1 << (itemCount + 1)) - 2; if (max == flag) { if (useDesc) { return 1; } else { return 0; } } long ans = 0; if (useDesc) { for (int i = 1; i <= itemCount; i++) { int key = 1 << i; if ((flag & key) == 0) { if (i > num) { ans++; } break; } } } else { for (int i = 1; i <= itemCount; i++) { int key = 1 << i; if ((flag & key) != 0) { continue; } if (i < num) { if (useDesc) { continue; } ans += this.GetAns(i, flag + key, true); } else { ans += this.GetAns(i, flag + key, useDesc); } } } return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 2 1 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }