#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int X, Y;
    while (cin >> X >> Y, (X || Y)) {
        vector<vector<int>> sketch(Y, vector<int>(X, 0));
        for (int i=0; i<Y; ++i) {
            for (int j=0; j<X; ++j) {
                cin >> sketch[i][j];
            }
        }
        int dp[15][15] = {};
        int pattern = 0;
        for (int i=0; i<Y; ++i) {
            for (int j=0; j<X; ++j) {
                if (i == 0 && sketch[i][j] == 0) {
                    dp[i][j] = 1;
                }
                if (sketch[i][j] == 0) {
                    if (Y <= i+1) {
                        pattern += dp[i][j];
                        continue;
                    }
                    if (0 <= j-1 && sketch[i+1][j-1] == 0) {
                        dp[i+1][j-1] += dp[i][j];
                    }
                    if (sketch[i+1][j] == 0 || sketch[i+1][j] == 2) {
                        dp[i+1][j] += dp[i][j];
                    }
                    if (j+1 < X && sketch[i+1][j+1] == 0) {
                        dp[i+1][j+1] += dp[i][j];
                    }
                } else if (sketch[i][j] == 2) {
                    if (Y <= i+2) {
                        pattern += dp[i][j];
                        continue;
                    }
                    if (sketch[i+2][j] == 0 || sketch[i+2][j] == 2) {
                        dp[i+2][j] += dp[i][j];
                    }
                }
            }
        }
        cout << pattern << endl;
    }
    return 0;
}