#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, c[15][15], dp[15][15];
int main() {
	while(scanf("%d%d", &W, &H), H) {
		memset(c, 0, sizeof(c));
		memset(dp, 0, sizeof(dp));
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) scanf("%d", &c[i][j]);
		}
		for(int i = 0; i < W; i++) {
			if(c[0][i] == 0) dp[0][i] = 1;
		}
		for(int i = 1; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(c[i][j] == 1) continue;
				if(i != H && c[i - 1][j] == 0) dp[i][j] = dp[i - 1][j];
				if(i != H && c[i][j] == 0 && j != 0 && c[i - 1][j - 1] == 0) dp[i][j] += dp[i - 1][j - 1];
				if(i != H && c[i][j] == 0 && j + 1 != W && c[i - 1][j + 1] == 0) dp[i][j] += dp[i - 1][j + 1];
				if(i > 1 && c[i - 2][j] == 2) dp[i][j] += dp[i - 2][j];
			}
		}
		int ret = 0;
		for(int i = 0; i < W; i++) {
			ret += dp[H - 1][i];
			if(c[H - 2][i] == 2) ret += dp[H - 2][i];
		}
		printf("%d\n", ret);
	}
}