#include<iostream>
using namespace std;
int main(){

    int w,h;
    while(cin>>w>>h){
        int data[16][16]={{0}},dp[17][17]={{0}};
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>data[i][j];
                if(i==0&&data[i][j]!=1)dp[i][j]=1;
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(dp[i][j]!=0){
                    if(data[i][j]==0){
                        if(i!=h-1&&j!=0&&data[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
                        if(data[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
                        if(i!=h-1&&j!=w-1&&data[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
                    }
                    else if(data[i][j]==2){
                        if(i==h-1)dp[i+1][j]+=dp[i][j];
                        else if(data[i+2][j]!=1)dp[i+2][j]+=dp[i][j];
                    }
                }
            }
        }
        /*
        cout<<endl;
        for(int i=0;i<=h;i++){
            cout<<i<<":";
            for(int j=0;j<w;j++){
                cout<<dp[i][j]<<" ";
            }
            cout<<endl;
        }*/
        int ans=0;
        for(int j=0;j<w;j++)ans+=dp[h][j];
        cout<<ans<<endl;
    }
    return 0;
}