#include <iostream>
using namespace std;

const int MAX_SIZE = 15;
char field[MAX_SIZE+1][MAX_SIZE+3];
int dp[MAX_SIZE+1][MAX_SIZE+3];
int w, h;

bool judge(int i, int j){
	if(j > 0 && j <= w && field[j][i] == '0' && j <= h)
		return true;
	return false;
}

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) break;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++)
				cin >> field[j][i];
		}
		int pattern = 0;
		for(int i = 0; i < MAX_SIZE+1; i++){
			for(int j = 0; j < MAX_SIZE+3; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i <= w; i++){
			if(field[i][1] == '0')
				dp[i][1] = 1;
		}
		for(int i = 1; i < h; i++){
			for(int j = 1; j <= w; j++){
				if(field[j][i] == '2'){
					dp[j][i+2] += dp[j][i];
				}else if(field[j][i] == '0'){
					if(field[j][i+1] != '1') dp[j][i+1] += dp[j][i];
					if(judge(i+1, j-1)) dp[j-1][i+1] += dp[j][i];
					if(judge(i+1, j+1)) dp[j+1][i+1] += dp[j][i];
				}else{
					dp[j][i] = 0;
				}
			}
			
		}
		int count = 0;
		for(int i = h; i <= h+1; i++){
			for(int j = 1; j <= w; j++){
				count += dp[j][i];
			}
		}
		cout << count << endl;
	}
	return 0;
}