#include <iostream>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;

int ms[11][11],br;

queue<pair<int, int> > st;

int main()
{
    int r, s;
    scanf ("%d %d", &r, &s);
    for (int i=0;i<r;++i)
    {
        for (int j=0;j<s;++j)
        {
            char a;
            scanf("\n%c", &a);
            if (a!='.')
               --ms[i][j];
        }
    }
    int dx[4]={-1, 0, 1, 0};
    int dy[4]={ 0, 1, 0,-1};
    ms[r-1][s-1]=1;
    st.push(make_pair(r-1, s-1));
    while (!st.empty())
    {
        pair<int, int> v=st.front();
        st.pop();
        for (int k=0;k<4;++k)
        {
            if (v.first+dx[k]>=0 && v.second+dy[k]>=0)
               if (v.first+dx[k]<r && v.second+dy[k]<s)
               {
                  if (ms[v.first+dx[k]][v.second+dy[k]]==0)
                  {
                      st.push(make_pair(v.first+dx[k], v.second+dy[k]));
                      for (int l=0;l<4;++l)
                      {
                          if (v.first+dx[k]+dx[l]>=0 && v.second+dy[k]+dy[l]>=0)
                             if (v.first+dx[k]+dx[l]<r && v.second+dy[k]+dy[l]<s)
                                if (ms[v.first+dx[k]+dx[l]][v.second+dy[k]+dy[l]]>0)
                                    ms[v.first+dx[k]][v.second+dy[k]]+=ms[v.first+dx[k]+dx[l]][v.second+dy[k]+dy[l]];
                      }
                  }
               }
        }
    }
    if (ms[0][0]==-1)
       printf("0\n");
    else
       printf("%d\n", ms[0][0]);
    system ("pause");
    return 0;
}
