#include <iostream>
using namespace std;

int main(){
	int x,y;
	while(1){
		cin >> x >> y;
		if(!x) break;
		int dp[17][15] = {},field[17][15] = {};
		for(int i = 1;i <= y;i++){
			for(int j = 0;j < x;j++) cin >> field[i][j];
		}
		for(int i = 0;i < x;i++) dp[0][i] = 1;
		for(int i = 0;i <= y;i++){
			for(int j = 0;j < x;j++){
				if(field[i][j] == 1) continue;
				if(i == 0){
					if(field[i + 1][j] != 1) dp[i + 1][j] = dp[i][j];
				}
				else if(field[i][j] == 0){
					if(i != y){
						if(j >= 1 && field[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
						if(j <= x - 2 && field[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
					}
					if(field[i + 1][j] != 1) dp[i + 1][j] += dp[i][j];
				}else{
					if(field[min(i + 2,y + 1)][j] != 1) dp[min(i + 2,y + 1)][j] += dp[i][j];
				}
			}
		}
		int cnt = 0;
		for(int i = 0;i < x;i++) cnt += dp[y + 1][i];
		cout << cnt << endl;
	}
	return 0;
}