#include <cstring>
#include <iostream>
using namespace std;
const int MAX_W = 15;
const int MAX_H = 15;

int w, h;
int field[MAX_H + 1][MAX_W];
int dp[MAX_H + 1][MAX_W];

void printfield() {
	for (int i = 0; i <= h; i++) {
		for (int j = 0; j < w; j++) {
			cout << '\t' << dp[i][j];
		}
		cout << endl;
	}
}

int main () {
	while (cin >> w >> h, w || h) {
		memset(field, 0, sizeof(field));
		memset(dp, 0, sizeof(dp));
		for (int i = 1; i <= h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> field[i][j];
			}
		}
		for (int i = 0; i < w; i++) {
			if (field[1][i] == 0) dp[1][i] = 1;
		}
		
		for (int i = 2; i <= h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i - 2][j] == 2 && field[i][j] != 1) {
					dp[i][j] += dp[i - 2][j];
				}
				if (field[i][j] == 0) {
					for (int dx = -1; dx <= 1; dx++) {
						int fx = j + dx;
						if (fx < 0 || w <= fx) continue;
						int fy = i - 1;
						if (field[fy][fx] != 0) continue;
						dp[i][j] += dp[fy][fx];
					}
				}
				else if (field[i][j] == 2) {
					dp[i][j] += dp[i - 1][j];
				}
			}
		}
		int sum = 0;
		for (int i = 0; i < w; i++) {
			sum += dp[h][i];
			if (field[h - 1][i] == 2) sum += dp[h - 1][i];
		}
		cout << sum << endl;
	}
	return 0;
}