#include<iostream>
#include<cstring>

int X, Y;
int field[15][15];
int dp[15][15];

int main()
{
	while( std::cin >> X >> Y, X | Y )
	{
		memset( field, -1, sizeof( field ) );
		memset( dp, 0, sizeof( dp ) );

		for( int i = 0; i != Y; ++i )
			for( int j = 0; j != X; ++j )
				std::cin >> field[i][j];

		for( int i = 0; i != X; ++i )
			if( field[0][i] != 1 )
				dp[0][i] = 1;
		
		for( int i = 1; i != Y; ++i )
		{
			for( int j = 0; j != X; ++j )
			{
				if( i < Y && field[i][j] != 1 )
				{
					for( int k = -1; k <= 1; ++k )
					{	
						if( field[i][j] == 2 && k )
							continue;

						if( j + k >= 0 && j + k < X && !field[i-1][j+k] )
							dp[i][j] += dp[i-1][j+k];
					}
				}

				if( i - 2 >= 0 && field[i][j] != 1 && field[i-2][j] == 2 )
					dp[i][j] += dp[i-2][j];
			}
		}

		
		int ans = 0;
		for( int j = 0; j != X; ++j )
		{
			ans += dp[Y-1][j];

			if( Y >= 2 && field[Y-2][j] == 2 )
				ans += dp[Y-2][j];
		}

		std::cout << ans << std::endl;
	}

	return 0;
}