#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int wide, tall, field[16][16], memo[16][16];

int skiing(int x, int y, bool ok)
{
	if( x < 0 || x >= wide || field[y][x] == 1 || field[y][x] == 2 && ok == true )
	{
		return 0;
	}
	else if( y >= tall - 1 )
	{
		return 1;
	}

	if( memo[y][x] != -1 )
	{
		return memo[y][x];
	}

	if( field[y][x] == 2 )
	{
		return memo[y][x] = skiing(x, y+2, false);
	}
	else
	{
		return memo[y][x] = skiing(x-1, y+1, true) + skiing(x, y+1, false) + skiing(x+1, y+1, true);
	}
}

int main()
{
	int cnt;
	while( cin >> wide >> tall )
	{
		if( wide == 0 && tall == 0 )
		{
			break;
		}

		memset(memo, -1, sizeof(memo));

		for(int i = 0; i < tall; i++)
		{
			for(int j = 0; j < wide; j++)
			{
				cin >> field[i][j];
			}
		}
		cnt = 0;
		for(int i = 0; i < wide; i++)
		{
			cnt += skiing(i, 0, false);
		}

		cout << cnt << endl;
	}
}