#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen

using namespace std;
// 0 :Ú®Â\Å é
// 1 :áQ¨ª é
// 2 :Wväª é
int field[15+1][15];
int memo[15+1][15];
int main()
{
	const int dir[][2] = {  { 1, -1 }, { 1, 0 }, { 1, 1 } };
//	cut here before submit 
//	freopen ("testcase.new_plan", "r", stdin );
	int X, Y;

	while (cin >> X >> Y && X && Y ){
		memset (field, 0, sizeof (field ) );
		memset (memo, 0, sizeof (memo) );

		for (int i = 0; i < Y; ++i ){
			for (int j = 0; j < X; ++j ){
				cin >> field[i][j];
			} // end for
		} // end for
		
		for (int j = 0; j < X; ++j ){ 
			field[Y][j] = 0;
			memo[Y][j] = 1;
		} // end for

		for (int j = 0; j < X; ++j ){
			if (field[Y-1][j] == 0 || field[Y-1][j] == 2 ){
				memo[Y-1][j] = 1;
			} // end if
		} // end for
		
		for (int i = Y - 2; i >= 0 ; --i ){
			for (int j = 0; j < X; ++j ){
				if (field[i][j] == 1 ){
					continue;
				}else
				if (field[i][j] == 0 ){
					for (int k = 0; k < 3; ++k ){
						int ny = i + dir[k][0];
						int nx = j + dir[k][1];
						if (nx < 0 || nx >= X ){
							continue;
						} // end if
						if (field[ny][nx] == 1 ){
							continue;
						} // end if
						if ((k == 0 || k == 2) && field[ny][nx] == 2 ){
							continue;
						} // end if
						if (field[ny][nx] == 2 && field[ny+2][nx] == 1 ){
							continue;
						} // end if
						memo[i][j] += memo[ny][nx];
					} // end for
				}else{ // if (field[i][j] == 2 )
					if (field[i+2][j] != 1 ){
						memo[i][j] += memo[i+2][j];
					} // end for
				} // end if
			} // end for
		} // end for
		
		int res = 0;
		for (int j = 0; j < X; ++j ){
			res += memo[0][j];
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}