#include<iostream>
#include<cstring>
 
#define rep(i,n) for(int i = 1; i <= n; i++)
 
#define MS   (15)
#define CM   (0)
#define TREE (1)
#define JUMP (2)
 
using namespace std;
 
int x, y;
int map[MS+1][MS+1];
int dp[MS+1][MS+1];
 
void check()
{
        rep(i,y-1) rep(j,x){
                if(map[i][j] == CM){
                        if(map[i+1][j] != TREE)  { dp[i+1][j]  +=dp[i][j]; }
                        if((j+1)<=x){
                                if(map[i+1][j+1]==CM){ dp[i+1][j+1]+=dp[i][j]; }
                        }
                        if((j-1)>=1){
                                if(map[i+1][j-1]==CM){ dp[i+1][j-1]+=dp[i][j]; }
                        }
                }
                if(map[i][j] == JUMP){
                        if(i+2 > y){
                                dp[y][j] += dp[i][j];
                        }
                        else if(map[i+2][j] != TREE){
                                dp[i+2][j]+=dp[i][j];
                        }
                }
        }
 
}
 
int main(void)
{
 
        while(cin >> x >> y && x){
                rep(i,y) rep(j,x){
                        cin >> map[i][j];
                }
 
                memset(dp, 0, sizeof(dp));
                
                rep(i,x)
                        if(map[1][i] != TREE){ dp[1][i]++; }
                
                check();
                
                int sum=0;
                
                rep(i,x){ sum += dp[y][i]; }
                
                cout << sum << endl;
                
        }
 
        return 0;
}