#include<iostream>
using namespace std;

int main(){
	int w,h,x,y;
	char map[15][15];
	int dp[15][15];
	int ans;
	
	while(cin>>w>>h,w!=0){
		for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			cin>>map[x][y];
			dp[x][y]=0;
		}
		}

		for(x=0;x<w;x++) if(map[x][0]!='1') dp[x][0]=1;

		for(y=0;y<h-1;y++){
		for(x=0;x<w;x++){
			if(map[x][y]=='0'){
				if(map[x][y+1]!='1') dp[x][y+1]+=dp[x][y];
				if(0<x && map[x-1][y+1]=='0') dp[x-1][y+1]+=dp[x][y];
				if(x<h-1 && map[x+1][y+1]=='0') dp[x+1][y+1]+=dp[x][y];
			}else if(map[x][y]=='2'){
				if(y<h-2 && map[x][y+2]!='1') dp[x][y+2]+=dp[x][y];
			}
		}
		}
		
		ans=0;for(x=0;x<w;x++){
			if(map[x][h-2]=='2') ans+=dp[x][h-2];
			ans+=dp[x][h-1];
		}
		cout<<ans<<endl;
	}
	return 0;
}