#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <limits>
using namespace std;
#ifdef mycom
ifstream fin("input");
#else
#define fin cin
#endif
char chess[100][100] = {0,};
int n, k;
long long total = 0;
bool possible(int y, int x)
{
int newy = y;
int newx = x;
for( ; newy >= 0 && newx >= 0; newy--, newx--)
{
if(chess[newy][newx] == true)
{
return false;
}
}
newy = y;
newx = x;
for( ; newy < n && newx < n; newy++, newx++)
{
if(chess[newy][newx] == true)
{
return false;
}
}
newy = y;
newx = x;
for( ; newy < n && newx >= 0; newy++, newx--)
{
if(chess[newy][newx] == true)
{
return false;
}
}
newy = y;
newx = x;
for( ; newy >= 0 && newx < n; newy--, newx++)
{
if(chess[newy][newx] == true)
{
return false;
}
}
return true;
}
inline bool sizecompare(int _y, int _x, int __y, int __x)
{
//_ 가 크면 true;
if(_y != __y)
return _y > __y;
else if(_y == __y)
{
return _x > __x;
}
}
void back(int selcount, int lasty, int lastx)
{
if(selcount == k)
{
total++;
}
else
{
for(int y=0; y<n; y++)
{
for(int x=0; x<n; x++)
{
if(sizecompare(y, x, lasty, lastx) && possible(y, x))
{
chess[y][x] = true;
back(selcount+1, y, x);
chess[y][x] = false;
}
}
}
}
}
int main()
{
bool bfirst = true;
while(fin >> n >> k && n != 0 && k != 0)
{
if(bfirst != true)
{
cout << endl;
}
bfirst = false;
total = 0;
back(0, -1, 0);
cout << total;
}
return 0;
}