#include<iostream>
using namespace std;

#define MAX 15
#define BLANK 0
#define BARRIER 1
#define JUMP 2
int main()
{
  int X,Y,field[MAX][MAX],dp[MAX][MAX],i,j,sum;
  while(cin>>X>>Y,X|Y){
    for(i=0;i<Y;i++)for(j=0;j<X;j++){cin>>field[i][j];dp[i][j]=(i==0);}
    for(i=1;i<Y;i++){
      for(j=0;j<X;j++){
	if(field[i][j]==BARRIER)continue;
	if(field[i-1][j]==BLANK)dp[i][j]+=dp[i-1][j];
	if(j+1<X && field[i-1][j+1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j+1];
	if(j-1>=0 && field[i-1][j-1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j-1];
	if(i-2>=0 && field[i-2][j]==JUMP)dp[i][j]+=dp[i-2][j];
      }
    }
    sum=0;
    for(j=0;j<X;j++){
      if(field[Y-1][j]==BLANK)sum+=dp[Y-1][j];
      if(Y-2>=0 && field[Y-2][j]==JUMP)sum+=dp[Y-2][j];
    }
    cout<<sum<<endl;
  }
}