#include <iostream>
#include <cstring>
using namespace std;

int c[17][15];
int p[17][15];

int main() {
    int w, h;
    while (cin >> w >> h, w|h) {
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                int ci;
                cin >> ci;
                c[y][x] = ci;
            }
        }
        for (int x = 0; x < w; x++) {
            c[h][x] = c[h+1][x] = 2;
        }
        memset(p, 0, sizeof(p));
        for (int y = 0; y < h+2; y++) {
            for (int x = 0; x < w; x++) {
                if (c[y][x] == 1) {
                    continue;
                }
                if (y == 0) {
                    p[y][x] = 1;
                    continue;
                }
                if (c[y][x] == 0) {
                    if (x > 0 && c[y-1][x-1] == 0) {
                        p[y][x] += p[y-1][x-1];
                    }
                    if (x+1 < w && c[y-1][x+1] == 0) {
                        p[y][x] += p[y-1][x+1];
                    }
                }
                if (c[y-1][x] == 0) {
                    p[y][x] += p[y-1][x];
                }
                if (y >= 2 && c[y-2][x] == 2) {
                    p[y][x] += p[y-2][x];
                }
            }
        }
        int ans = 0;
        for (int y = h; y < h+2; y++) {
            for (int x = 0; x < w; x++) {
                ans += p[y][x];
            }
        }
        cout << ans << endl;
    }
}