#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_XY = 16;

void solve();

int x, y, f[MAX_XY][MAX_XY], dp[MAX_XY][MAX_XY];

int main(){
    cin >>x >>y;
    rep(i, MAX_XY) rep(j, MAX_XY) f[i][j] = 1;
    rep(i, y) rep(j, x) cin >>f[i][j];
    memset(dp, 0, sizeof(dp));

    solve();

    int ans = 0;
    rep(i, x) ans += dp[y][i];
    cout <<ans <<endl;
    return 0;
}

void solve(){
    rep(i, x){
        if(f[0][i] == 0) dp[0][i] = 1;
    }

    rep(i, y - 1){
        rep(j, x){
            if(f[i + 1][j] == 1){
                dp[i + 1][j] = 0;
                continue;
            } else if(f[i + 1][j] == 0){
                f(k, -1, 2){
                    if(j + k < x && j + k >= 0) dp[i + 1][j] += dp[i][j + k];
                }
            } else{
                dp[i + 1][j] += dp[i][j];
                if(i + 3 >= y) dp[y][j] += dp[i + 1][j];
                else dp[i + 3][j] += dp[i + 1][j];
                dp[i + 1][j] = 0;
            }
        }
    }
    rep(i, x) dp[y][i] += dp[y - 1][i];
}