#include <cstdio>
int a[16][16];
long long dp[18][16];
int main()
{
    while (true) {
        int h, w;
        scanf("%d%d", &w, &h);
        if (!(w | h)) break;
        for (int i = 0; i < 16; ++i) for (int j = 0; j < 16; ++j)
            dp[i][j] = 0;
        for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j)
            scanf("%d", &a[i][j]);

        for (int j = 0; j < w; ++j)
            if (a[0][j] == 0) dp[0][j] = 1;
        for (int i = 1; i < h; ++i) for (int j = 0; j < w; ++j) {
            if (a[i][j] == 1) continue;
            if (a[i-1][j] != 2) dp[i][j] = dp[i-1][j];
            if (a[i][j] == 0) {
                if (j > 0 && a[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
                if (j < w-1 && a[i-1][j+1] == 0) dp [i][j] += dp[i-1][j+1];
            }
            if (i > 1 && a[i-2][j] == 2) dp[i][j] += dp[i-2][j];
        }
        for (int i = h; i < h+2; ++i) for (int j = 0; j < w; ++j) {
            dp[i][j] = dp[i-1][j];
            if (i > 1 && a[i-2][j] == 2) dp[i][j] += dp[i-2][j];
        }
        int res = 0;
        for (int j = 0; j < w; ++j) res += dp[h+1][j];
        printf("%d\n", res);
    }
    return 0;
}