#include <iostream>
#include<string.h>
using namespace std;

int course[15][15];
int pattern[16][16];

int main() {

  int X,Y,t,in;
  while(cin>>X>>Y, X|Y) {
    memset(course, 0, sizeof(course));
    memset(pattern, 0, sizeof(pattern));
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cin>>in;
	course[i][j] = in;
      }
    }

    for(int i=Y-1; i>=0; --i) {
      for(int j=X-1; j>=0; --j) {
	if(i==Y-1) {
	  if(course[i][j] == 0)
	    pattern[i][j] = 1;
	} else if(i == Y-2 && course[i][j] == 2){
	  pattern[i][j] = 1;
	} else {
	  if(course[i][j] == 0) {
	    pattern[i][j] = pattern[i+1][j];
	    if(j > 0 && course[i+1][j-1] == 0)
	      pattern[i][j] += pattern[i+1][j-1];
	    if(j < X && course[i+1][j+1] == 0)
	      pattern[i][j] += pattern[i+1][j+1];
	  }
	  if(course[i][j] == 2 && course[i+2][j] != 1) {
	    pattern[i][j] = pattern[i+2][j];
	  }
	}
      }
    }

    /*
    cout<<endl;
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cout<<pattern[i][j]<<" ";
      }
      cout<<endl;
    }
    cout<<endl;
    */
    int sum = 0;
    for(int i=0; i<X; ++i) {
      //cout<<pattern[0][i]<<" ";
      sum += pattern[0][i];
    }
    //cout<<endl;
    cout<<sum<<endl;
  }
}