#include <stdio.h>
long long visited[2005],N,P,res=0;
long long digit[2005];

void test()
{long long i,min=999999;

for (i=1;i<=N;i++)
	if (!visited[i]) {min=i;break;}
i=1;
while (min>digit[i] && digit[i])
	{i++;
	res++;
	}


return;
}


void gen(long long x)
{
long long i,min;

if (x==P+1) {test();
			 visited[digit[x-1]]=0;
			 return;
			 }

for (i=1;i<=N;i++)
	if (digit[x-1]<i)
	{digit[x]=i;visited[i]=1;gen(x+1);}

visited[digit[x-1]]=0;
return;
}

int main ()
{
scanf ("%d %d",&N,&P);

gen(1);


printf("%ld\n",res);

return 0;
}
