#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int W, H;
int C[20][20];
long long dp[20][20];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> W >> H) {
    if (W == 0 && H == 0) break;
    rep(x, 20) rep(y, 20) C[x][y] = dp[x][y] = 0;
    rep(i, H) rep(j, W) cin >> C[j][i];

    rep(x, W) {
      if (C[x][0] == 1) continue;
      dp[x][0] = 1;
    }
    long long s = 0;
    rep(y, H) {
      rep(x, W) {
        for (int d=-1; d<=1; d++) {
          int nx = x+d, ny = y+1;
          if (C[x][y] == 2) {
            if (d != 0) continue;
            ny = y+2;
          }
          if (nx < 0 || nx >= W || C[nx][ny] == 1) continue;
          if (C[nx][ny] == 2 && d != 0) continue;

          if (ny >= H) {
            if (d == 0) s += dp[x][y];
          }
          else dp[nx][ny] += dp[x][y];
        }
      }
    }
    cout << s << "\n";
  }
  return 0;
}