#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1e9 + 7;

int main()
{
	int W, H;
	cin >> H >> W;
	vector<string> mass(H);
	for (int i = 0; i < H; i++)
	{
		cin >> mass[i];
	}

	vector<vector<ll>> dp(H, vector<ll>(W, 0)), Xs(H, vector<ll>(2222, 0)), Ys(H, vector<ll>(W, 0)), Zs(H, vector<ll>(W, 0));
	dp[0][0] = 1;
	Xs[0][0] = 1, Ys[0][0] = 1, Zs[0][0] = 1;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (i == 0 && j == 0)
				continue;
			if (mass[i][j] == '#')
			{
				dp[i][j] = 0, Xs[i][i] = 0, Ys[i][j] = 0, Zs[i][j] = 0;
				continue;
			}

			if (j > 0)
				dp[i][j] += Xs[i][j - 1];
			if (i > 0)
				dp[i][j] += Ys[i - 1][j];
			if (i > 0 && j > 0)
				dp[i][j] += Zs[i - 1][j - 1];
			dp[i][j] %= mod;
			Xs[i][j] += dp[i][j], Ys[i][j] += dp[i][j], Zs[i][j] += dp[i][j];
			if (j > 0)
				(Xs[i][j] += Xs[i][j - 1]) %= mod;
			if (i > 0)
				(Ys[i][j] += Ys[i - 1][j]) %= mod;
			if (i > 0 && j > 0)
				(Zs[i][j] += Zs[i - 1][j - 1]) %= mod;
		}
	}

	cout << dp[H - 1][W - 1] << "\n";
}
#include<bits/stdc++.h>

/*

Pranav Here!!

*/

using namespace std;

#define pb push_back
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)

#define sz(x) (int)(x).size()

#define ff first
#define ss second

#define mp make_pair

#define ll long long
#define ld long double
#define lli long long int

#define mod 1000000007

ll powmod(ll a,  ll b){
    if(b==0){
        return 1 ;
    }
    ll x = powmod(a,b/2);
    x = (x*x)%mod ;
    if(b%2){
        x = (a*x)%mod ;
    }
    return x;
}

set<ll> prm;

void Sieve(ll n)
{
  bool prime[n+1];
  memset(prime,true, sizeof(prime));
  for(ll p=2;p*p<=n;p++)
  {
    if(prime[p]==true)
    {
      for(ll i=p*p;i<=n;i+=p)
      {
        prime[i]=false;
      }
    }
  }
  if(!prm.empty()) {
    prm.clear();
  }
  for(ll p=2;p<=n;p++)
  {
    if(prime[p])
    {
      prm.insert(p);
    }
  }
}

ll fact(ll n) {
    ll res = 1;
    for(ll i=2;i<=n;i++) {
        res*=i;
    }
    return res;
}

ll _lcm(ll x,ll y) {
    return x*y/__gcd(x,y);
}

ll _gcd(ll a,ll b) {
    if(!a) {
        return b%mod;
    }
    return _gcd((b%a)%mod,a%mod);
}

ll nCr(ll n,ll r) {
    return (ld)fact(n)/(ld)(fact(r)*fact(n-r));
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //Sieve(1000000);
    ll n,m;
    char ch;
    cin>>n>>m;
    char s[n][m];
    for(ll i=0;i<n;i++) {
        for(ll j=0;j<m;j++) {
            cin>>s[i][j];
        }
    }
    ll cnt=0;
    for(ll i=1;i<n;i++) {
        for(ll j=1;j<m;j++) {
            string r="";
            r+=s[i-1][j-1];
            r+=s[i-1][j];
            r+=s[i][j-1];
            r+=s[i][j];
            ll z=count(all(r),'#');
            if(z==1 || z==3) {
                cnt++;
            }
        }
    }
    cout<<cnt;
    return  0;
}
