#include <bits/stdc++.h>

using namespace std;

int X, Y;
int MapData[15][15];
int DpCount[16][15];

void solve() {
	int col, sum;
	int dx[] = { -1,0,1 };

	memset(DpCount, 0, sizeof(DpCount));
	for (int j = 0; j < X; ++j) {
		if (MapData[Y - 1][j] == 1) {
			continue;
		}
		DpCount[Y - 1][j] = 1;
	}

	for (int i = Y - 2; i >= 0; --i) {
		for (int j = 0; j < X; ++j) {
			if (MapData[i][j] == 1) {
				continue;
			}

			if (MapData[i][j] == 2) {
				if (i == Y - 2) {
					DpCount[i][j] = 1;
				}
				else {
					DpCount[i][j] = DpCount[i + 2][j];
				}
				continue;
			}

			sum = 0;
			for (int k = 0; k < 3; ++k) {
				col = j + dx[k];
				if (col < 0 || col > X - 1) {
					continue;
				}
				if (k != 1 && MapData[i + 1][col] == 2) {
					continue;
				}
				sum += DpCount[i + 1][col];
			}
			DpCount[i][j] = sum;
		}
	}

	sum = 0;
	for (int j = 0; j < X; ++j) {
		sum += DpCount[0][j];
	}
	cout << sum << endl;
}

int main() {

	while (cin >> X >> Y, X) {
		for (int i = 0; i < Y; ++i) {
			for (int j = 0; j < X; ++j) {
				cin >> MapData[i][j];
			}
		}
		solve();
	}

	return 0;
}
