#include<iostream>

using namespace std;

int map[15][15];

int count[15][15];

int main () {

	while(true) {
		int w, h;
		cin >> w >> h;

		if ( w == 0 )
			break;
	
		for ( int i=0; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				cin >> map[i][j];
			}
		}

		for ( int i=1; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				count[i][j] = 0;
			}
		}
		
		for ( int i=0; i<w; i++ ) {
			if ( map[0][i] == 0 )
				count[0][i] = 1;
		}

		for ( int i=1; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				if ( map[i][j] != 1 ) {
					if ( map[i][j] != 2 ) {
						if ( j-1 >= 0 ) {
							if ( map[i-1][j-1] == 0 ) {
								count[i][j] += count[i-1][j-1];
							}
						}

						if ( j+1 < w ) {
							if ( map[i-1][j+1] == 0 ) {
								count[i][j] += count[i-1][j+1];
							}
						}
					}
					if ( map[i-1][j] == 0 ) {
						count[i][j] += count[i-1][j];
					}

					if ( i-2 >= 0 ) {
						if ( map[i-2][j] == 2 ) {
							count[i][j] += count[i-2][j];
						}
					}
				}

			}
		}

		/*
		for ( int i=0; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				cout << count[i][j] << "\t";
			}
			cout << endl;
		}
		cout << endl;
		*/
		int sum = 0;

		for ( int i=0; i<w; i++ ) {
			sum += count[h-1][i];
		}

		for ( int i=0; i<w; i++ ) {
			if ( map[h-2][i] == 2 )
				sum += count[h-2][i];
		}

		cout << sum << endl;
	}
}
		