#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 16, W = 0, O = 1, J = 2;

int tile[MAXW][MAXW+ 5];
int dp[MAXW][MAXW];
int dx[3] = {0, -1, 1};

int main()
{
    int x, y;
    while(cin >> x >> y && x)
    {
        memset(dp, 0, sizeof(dp));
        memset(tile, W, sizeof(tile));
        rep(j,y)rep(i,x) cin >> tile[i][j];
        rep(i,x){ if(tile[i][0] == W) dp[i][0] = 1; }

        rep(i,x)
            if(tile[i][1] == W)
            {rep(k,3)if(i+dx[k]>=0 && i+dx[k]<x && tile[i+dx[k]][0] == W)dp[i][1] += dp[i + dx[k]][0];}
            else if(tile[i][1] == J && tile[i][0] == W) dp[i][1] += dp[i][0];
        for(int j=2;j<y;j++)rep(i,x)
        {

            if(tile[i][j] == O){ continue;}
            if(tile[i][j] == J)
            {
                if(tile[i][j-1] == W) dp[i][j] += dp[i][j-1];
                if(tile[i][j-2] == J) dp[i][j] += dp[i][j-2];
                continue;
            }
            rep(k,3)if((i+dx[k]>=0 && i+dx[k]< x)&& tile[i+dx[k]][j-1] == W)
                dp[i][j] += dp[i+dx[k]][j-1];
            if(tile[i][j-2] == J) dp[i][j] += dp[i][j-2];

        }
        //rep(j,y) { rep(i,x) cout << dp[i][j] << "\t"; cout << endl;}

        int ans = 0;
        REP(x){ ans += dp[i][y-1] ; if(tile[i][y-2] ==J) ans+= dp[i][y-2];}
        cout << ans << endl;
    }
    return 0;
}