#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

char field[18][18];
int dp[18][18][18];
int X, Y;

int DFS(int x, int y, int prex)
{
	if ((x < 0 || x >= X) || field[y][x] == '1' || (field[y][x] == '2' && x != prex))
	{
		return(0);
	}
	if (y >= Y - 1)
	{
		return(1);
	}
	if (dp[x][y][prex] != -1)
	{
		return(dp[x][y][prex]);
	}
	int ans = 0;
	if (field[y][x] == '2')
	{
		ans += DFS(x, y + 2, x);
	}
	else
	{
		ans += DFS(x - 1, y + 1, x);
		ans += DFS(x, y + 1, x);
		ans += DFS(x + 1, y + 1, x);
	}
	return(dp[x][y][prex] = ans);
}

void solve()
{
	while (cin >> X >> Y, X || Y)
	{
		for (int i = 0; i < Y; ++i)
		{
			for (int j = 0; j < X; ++j)
			{
				cin >> field[i][j];
			}
		}
		int ans = 0;
		memset(dp, -1, sizeof(dp));
		for (int i = 0; i < X; ++i)
		{
			ans += DFS(i, 0, 0);
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}