#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=2002;
char a[N][N];
int hor[N][N],ver[N][N],sum,mod=1e9+7,pwr[4000005];

int32_t main(){
   ios;
   int n,m;
   cin>>n>>m;

   pwr[0]=1;
   F(i,1,4000000) pwr[i]=pwr[i-1]*2%mod;

   F(i,1,n){
   	F(j,1,m){
   		cin>>a[i][j];
   		sum+=(a[i][j]=='.');
   	}
   }

   //precalculation
   F(i,1,n){
   	int prv=0;
   	F(j,1,m){
   		if(a[i][j]=='#') prv=j;
   		else hor[i][j]=j-prv-1;
   	}
   	prv=m+1;
   	R(j,m,1){
   		if(a[i][j]=='#') prv=j;
   		else hor[i][j]+=prv-j-1;
   	}
   }
   F(j,1,m){
   	int prv=0;
   	F(i,1,n){
   		if(a[i][j]=='#') prv=i;
   		else ver[i][j]=i-prv-1;
   	}
   	prv=n+1;
   	R(i,n,1){
   		if(a[i][j]=='#') prv=i;
   		else ver[i][j]+=prv-i-1;
   	}
   }

   //calculation
   int ans=0;
   F(i,1,n){
   	F(j,1,m){
   		if(a[i][j]=='#') continue;
   		
   		int tol=hor[i][j]+ver[i][j]+1;
   		int aa=(pwr[tol]-1+mod)%mod;
   		int bb=pwr[sum-tol];

   		ans+=aa*bb%mod;
   		ans%=mod;
   	}
   }
   cout<<ans<<endl;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = 998244353;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};

int bp(int x, int exp){
	int res = 1;
	while(exp){
		if(exp & 1) mul_self(res, x);
		mul_self(x, x);
		exp >>= 1;
	}
	return res;
}

int inv(int x){
	return bp(x, MOD - 2);
}


void solve(){
	int n, m;
	cin >> n >> m;
	vector<int> vec(m);
	for(auto &x : vec) cin >> x;
	vec.push_back(0);
	vec.push_back(n + 1);
	sort(all(vec));
	int mn = n;
	vector<int> df;
	for(int i = 1; i < m + 2; ++i){
		int x = vec[i] - vec[i - 1] - 1;
		if(x > 0){
			mn = min(mn, x);
			df.push_back(x);
		}
	}
	assert(mn > 0);
	int res = 0;
	for(auto &x : df){
		res += (x + mn - 1) / mn;
	}
	cout << res << '\n';
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	// freopen("tree.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}