#include <iostream>
#include <vector>

int main()
{
  int h = 0, w = 0, futon_counter = 0;
  std::string room = "";
  std::cin >> h >> w;
  for(int i = 0; i < h; ++i)
  {
    std::string tmp = "";
    std::cin >> tmp;
    room += tmp;
  }
  for(int i = 0; i < h * w; ++i)
  {
    if(room[i] == '#') continue;
    if(room[i + 1] == '.' && ( i + 1 < h * w) && ((i + 1) % w != 0)) ++futon_counter;
    if(room[i + w] == '.' && (i + w < h * w)) ++futon_counter;
  }
  std::cout << futon_counter << std::endl;
  return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const long long mod = 1000000007;
int cnt[4][2000][2000];
int main(void){
    int h, w;
    string s[2000];
    cin >> h >> w;
    for(int i=0;i<h;i++) cin >> s[i];

    vector< long long > p(h*w+1, 0);
    p[0] = 1;
    for(int i=1;i<=h*w;i++) p[i] = p[i-1]*2 % mod;

    int k = 0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(s[i][j] == '.') k++;


    for(int i=0;i<h;i++){
        cnt[0][i][0] = 0;
        for(int j=1;j<w;j++){
            if(s[i][j] == '#') continue;
            if(s[i][j-1] == '#'){
                cnt[0][i][j] = 0;
            }else{
                cnt[0][i][j] = cnt[0][i][j-1] + 1;
            }
        }

        cnt[1][i][w-1] = 0;
        for(int j=w-2;j>=0;j--){
            if(s[i][j] == '#') continue;
            if(s[i][j+1] == '#'){
                cnt[1][i][j] = 0;
            }else{
                cnt[1][i][j] = cnt[1][i][j+1] + 1;
            }
        }
    }

    for(int j=0;j<w;j++){
        cnt[2][0][j] = 0;
        for(int i=1;i<h;i++){
            if(s[i][j] == '#') continue;
            if(s[i-1][j] == '#'){
                cnt[2][i][j] = 0;
            }else{
                cnt[2][i][j] = cnt[2][i-1][j] + 1;
            }
        }

        cnt[3][h-1][j] = 0;
        for(int i=h-2;i>=0;i--){
            if(s[i][j] == '#') continue;
            if(s[i+1][j] == '#'){
                cnt[3][i][j] = 0;
            }else{
                cnt[3][i][j] = cnt[3][i+1][j] + 1;
            }
        }
    }

    long long ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '#') continue;
            int c = 1;
            for(int l=0;l<4;l++) c += cnt[l][i][j];
            ans += p[k-c] * (p[c] - 1) % mod;
        }
    }
    cout << ans%mod << endl;
}
