#include <iostream>
#include <queue>
#include <map>
#include <string.h>

using namespace std;

const int FIELD_MAX =15;

int X, Y;
int field[FIELD_MAX][FIELD_MAX];
int table[FIELD_MAX+1][FIELD_MAX];
int cnt = 0;

typedef pair<int, int> point;

void solve()
{
	memset(&table[0][0], 0, sizeof(int) * 15 * 16);
	for(int x=0; x<X; x++)
	{
		table[Y][x] = 1;
	}
	
	for(int y=Y; y>=1; y--)
	{	
		for(int x=0; x<X; x++){
			if(field[y][x] ==1)
			{
				continue;
			}
			
			if(y>=2){
				if(field[y-2][x]==2) table[y-2][x]+=table[y][x];
			}
			if(x>=1 && y!=Y && field[y][x] != 2){
				if(field[y-1][x-1]==0) table[y-1][x-1]+=table[y][x];
			}
			if(field[y-1][x]==0) table[y-1][x]+=table[y][x];
			if(x<X-1 && y!=Y && field[y][x] != 2){
				if(field[y-1][x+1]==0) table[y-1][x+1]+=table[y][x];
			}
		}
	}
	
	cnt = 0;
	for(int x=0; x<X; x++){
		cnt += table[0][x];
	}
}

int main()
{
	while( 1 )
	{
		cin >> X >> Y;
		if(X==0 && Y==0)
		{
			break;
		}
		
		for(int y=0; y<Y; y++)
		{
			for(int x=0; x<X; x++)
			{
				cin >> field[y][x];
			}
		}
		
		cnt = 0;
		solve();
		printf("%d\n", cnt);
	}
}