N,K=map(int,input().split()) a=0 for i in range(1,(1<>j)&1)] c=[j+1 for j in range(N)if not((i>>j)&1)] if min(b)==K and max(b)>min(c): a+=1 print(a)