#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
using namespace std;

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 1000000007

typedef vector<int> vint;
typedef long long ll;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        ll sum=0;
        int h,w;
        int K=0;
        
        cin>>h>>w;
        
        char map[h+5][w+5];

        rep(i,h){
                string s;
                cin>>s;
                rep(j,w){
                        map[i][j]=s[j];
                        if(s[j]=='.') K++;
                }
        }

        int yoko[h+5][w+5];
        int tate[h+5][w+5];

        rep(i,h){
                int index=0;
                int cnt=0;
                while(index<w){
                        while(map[i][index]=='.'){
                                cnt++;
                                index++;
                                if(index==w)break;
                        }
                        for(int j=index-cnt;j<index;j++){
                                yoko[i][j]=cnt;
                        }
                        cnt=0;
                        index++;
                }
        }
        rep(j,w){
                int index=0;
                int cnt=0;
                while(index<h){
                        while(map[index][j]=='.'){
                                cnt++;
                                index++;
                                if(index==h) break;
                        }
                        for(int i=index-cnt;i<index;i++){
                                tate[i][j]=cnt;
                        }
                        cnt=0;
                        index++;
                }
        }

        rep(i,h){
                rep(j,w){
                        if(map[i][j]=='.'){
                                sum = (sum + modpow(2,K-(tate[i][j]+yoko[i][j] - 1)))%MOD;
                        }
                }
        }

        cout << ((K*modpow(2,K))%MOD-sum+MOD)%MOD <<endl;


        return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define double long double
#define all(x) x.begin(),x.end()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
#define gog(T,x) cout<<"Case #"<<T<<": "<<x<<"\n";
int main()
{
	fast_io //REMOVE FOR interactive problems
	lli n,x;
	cin>>n>>x;
	string s;
	cin>>s;
	forn(i,n)
	{
		if(s[i]=='o')
			x++;
		else
			x=max(0LL,x-1);
	}
	cout<<x;
}

