#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MAX = 17;
int in[MAX][MAX], X,Y,data[MAX][MAX],ans;
int dx[4] = {-1,0,1};


void init(){
  memset(data,0,sizeof(data));
  ans = 0;
}


void solve(){
  for(int i = 1; i <= Y; i++)
    for(int j = 1; j <= X; j++){
      for(int k = 0; k < 3; k++)
	if(in[i][j] == 0){
	  int f = j+dx[k];
	  if(i-1 > 0 && 0 < f && f <= X){
	    if(in[i-1][f] != 2) data[i][j] += data[i-1][f];
	    // if(i-2 > 0 && in[i-1][f] == 2) data[i][j] += data[i-2][f];
	  }

	}else if(in[i][j] == 2){
	  if(i-1 > 0) data[i][j] += data[i-1][j];
	  if(i+2 <= Y) data[i+2][j] += data[i][j];
	  break;
	}
	/*
	if(i-1 > 0 && j+dx[k] > 0 && j+dx[k] <= X && in[i][j] != 1 && in[i-1][j+dx[k]] != 2){
	  if(in[i][j] == 2) data[i][j] = data[i-1][j];
	  else data[i][j] += data[i-1][j+dx[k]];
	}
      if(i-2 > 0 && in[i-2][j] == 2 && in[i][j] != 1) data[i][j] += data[i-2][j];
	*/
    }

  for(int j = 1; j <= X; j++){
    if(Y-1 > 0 && in[Y-1][j] == 2) ans+=data[Y-1][j];
    ans+=data[Y][j];
  }
  cout << ans << endl;
}

void print(){
  for(int i = 1; i <= Y; i++){
    for(int j = 1; j <= X; j++)
      cout << data[i][j]<< " ";
    cout << endl;
  }
}
int main(){
  while(cin >> X >> Y && X+Y){
    init();
    for(int i = 1; i <= Y; i++)
      for(int j = 1; j <= X; j++)
	cin >> in[i][j];
    
    for(int i = 1; i <= X; i++)
      if(in[1][i] == 0) data[1][i] = 1;

    solve();
    //print();
  }
  return 0;
}