#include<bits/stdc++.h>
#define ll long long
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
const int N=3009;
char s[N][N];
int _1[N][N],_2[N][N];
int dd[N][N],dr[N][N],rr[N][N],rd[N][N];
int rrsum[2*N];
int drsum[2*N];
int rdsum[2*N];
int ddsum[2*N];
ll ans,num;
int cnt[2*N];
int n,m;
pii kkr[2*N],kkd[2*N];
void solve()
{
int x=1,y=1;
kkr[2]=kkd[2]=mp(1,1);
while(x!=n||y!=m)
{
if(x<n && s[x+1][y]=='.') ++x;
else ++y;
kkd[x+y]=mp(x,y);
}
x=y=1;
while(x!=n||y!=m)
{
if(y<m && s[x][y+1]=='.') ++y;
else ++x;
kkr[x+y]=mp(x,y);
}
}
void chkmax(int &a,int b)
{
if(b>a) a=b;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m;
F(i,1,n)cin>>s[i]+1;
_1[1][1]=s[1][1]=='.';F(i,1,n)F(j,1,m) if(s[i][j]=='.') _1[i][j]|=_1[i][j-1]|_1[i-1][j];
_2[n][m]=s[n][m]=='.';G(i,n,1)G(j,m,1) if(s[i][j]=='.') _2[i][j]|=_2[i][j+1]|_2[i+1][j];
F(i,1,n)F(j,1,m)if(s[i][j]=='.'&&!(_1[i][j]&&_2[i][j]))s[i][j]='^';
F(i,1,n)F(j,1,m)cnt[i+j]+=s[i][j]=='.',num+=s[i][j]!='*';
if(s[1][1]!='.')
{
cout<<num*(num-1)/2<<'\n';
return 0;
}
F(i,2,n+m) if(cnt[i]==1) ans+=--num;
solve();
G(i,n,1)G(j,m,1)
{
if(s[i][j]!='.') continue;
if(kkd[i+j+1]==mp(i,j+1)) dd[i][j]=i+j+1;
else if(kkr[i+j+1]!=mp(i,j+1))chkmax(dd[i][j],dd[i][j+1]);
if(kkd[i+1+j]==mp(i+1,j)) chkmax(dd[i][j],i+j+1);
else if(kkr[i+j+1]!=mp(i+1,j))chkmax(dd[i][j],dd[i+1][j]);
}
G(i,n,1)G(j,m,1)
{
if(s[i][j]!='.') continue;
if(kkr[i+j+1]==mp(i,j+1)) rr[i][j]=i+j+1;
else if(kkd[i+j+1]!=mp(i,j+1))chkmax(rr[i][j],rr[i][j+1]);
if(kkr[i+1+j]==mp(i+1,j)) chkmax(rr[i][j],i+j+1);
else if(kkd[i+j+1]!=mp(i+1,j))chkmax(rr[i][j],rr[i+1][j]);
}
F(i,1,n+m) ddsum[i]=max(ddsum[i-1],dd[kkd[i].x][kkd[i].y]);
F(i,1,n+m) rrsum[i]=max(rrsum[i-1],rr[kkr[i].x][kkr[i].y]);
F(i,1,n+m) rdsum[i]=max(rdsum[i-1],dd[kkr[i].x][kkr[i].y]);
F(i,1,n+m) drsum[i]=max(drsum[i-1],rr[kkd[i].x][kkd[i].y]);
F(i,2,n+m)
F(j,2,n+m)
{
if(cnt[i]==1 || cnt[j]==1) continue;
// cout<<i<<"-"<<j<<":"<<rdsum[i-1]<<" "<<rrsum[i-1]<<" "<<ddsum[j-1]<<" "<<drsum[j-1]<<'\n';
if(max(rdsum[i-1],ddsum[j-1])>j || max(drsum[j-1],rrsum[i-1])>i) continue;
ans++;
}
cout<<ans<<'\n';
}
/*#include<bits/stdc++.h>
#define ll long long
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
const int N=3009;
char s[N][N];
int _1[N][N],_2[N][N];
int dd[N][N],dr[N][N],rr[N][N],rd[N][N];
int rrsum[2*N];
int drsum[2*N];
int rdsum[2*N];
int ddsum[2*N];
ll ans,num;
int cnt[2*N];
int n,m;
pii kkr[2*N],kkd[2*N];
void solve()
{
int x=1,y=1;
kkr[2]=kkd[2]=mp(1,1);
while(x!=n||y!=m)
{
if(x<n && s[x+1][y]=='.') ++x;
else ++y;
kkd[x+y]=mp(x,y);
}
x=y=1;
while(x!=n||y!=m)
{
if(y<m && s[x][y+1]=='.') ++y;
else ++x;
kkr[x+y]=mp(x,y);
}
}
void chkmax(int &a,int b)
{
if(b>a) a=b;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m;
F(i,1,n)cin>>s[i]+1;
_1[1][1]=s[1][1]=='.';F(i,1,n)F(j,1,m) if(s[i][j]=='.') _1[i][j]|=_1[i][j-1]|_1[i-1][j];
_2[n][m]=s[n][m]=='.';G(i,n,1)G(j,m,1) if(s[i][j]=='.') _2[i][j]|=_2[i][j+1]|_2[i+1][j];
F(i,1,n)F(j,1,m)if(s[i][j]=='.'&&!(_1[i][j]&&_2[i][j]))s[i][j]='^';
F(i,1,n)F(j,1,m)cnt[i+j]+=s[i][j]=='.',num+=s[i][j]!='*';
if(s[1][1]!='.')
{
cout<<num*(num-1)/2<<'\n';
return 0;
}
F(i,2,n+m) if(cnt[i]==1) ans+=--num;
solve();
G(i,n,1)G(j,m,1)
{
if(s[i][j]!='.') continue;
if(kkd[i+j+1]==mp(i,j+1)) dd[i][j]=i+j+1;
else if(kkr[i+j+1]!=mp(i,j+1))chkmax(dd[i][j],dd[i][j+1]);
if(kkd[i+1+j]==mp(i+1,j)) chkmax(dd[i][j],i+j+1);
else if(kkr[i+j+1]!=mp(i+1,j))chkmax(dd[i][j],dd[i+1][j]);
}
G(i,n,1)G(j,m,1)
{
if(s[i][j]!='.') continue;
if(kkr[i+j+1]==mp(i,j+1)) rr[i][j]=i+j+1;
else if(kkd[i+j+1]!=mp(i,j+1))chkmax(rr[i][j],rr[i][j+1]);
if(kkr[i+1+j]==mp(i+1,j)) chkmax(rr[i][j],i+j+1);
else if(kkd[i+j+1]!=mp(i+1,j))chkmax(rr[i][j],rr[i+1][j]);
}
F(i,1,n+m) ddsum[i]=max(ddsum[i-1],dd[kkd[i].x][kkd[i].y]);
F(i,1,n+m) rrsum[i]=max(rrsum[i-1],rr[kkr[i].x][kkr[i].y]);
F(i,1,n+m) rdsum[i]=max(rdsum[i-1],dd[kkr[i].x][kkr[i].y]);
F(i,1,n+m) drsum[i]=max(drsum[i-1],rr[kkd[i].x][kkd[i].y]);
F(i,2,n+m)
F(j,2,n+m)
{
if(cnt[i]==1 || cnt[j]==1) continue;
// cout<<i<<"-"<<j<<":"<<rdsum[i-1]<<" "<<rrsum[i-1]<<" "<<ddsum[j-1]<<" "<<drsum[j-1]<<'\n';
if(max(rdsum[i-1],ddsum[j-1])>j || max(drsum[j-1],rrsum[i-1])>i) continue;
ans++;
}
cout<<ans<<'\n';
}#include<bits/stdc++.h>
#define ll long long
#define F(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define G(i,l,r) for(int i=(l),i##end=(r);i>=i##end;--i)
#define x first
#define y second
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ep emplace_back
using namespace std;
const int N=3009;
char s[N][N];
int _1[N][N],_2[N][N];
int dd[N][N],dr[N][N],rr[N][N],rd[N][N];
int rrsum[2*N];
int drsum[2*N];
int rdsum[2*N];
int ddsum[2*N];
ll ans,num;
int cnt[2*N];
int n,m;
pii kkr[2*N],kkd[2*N];
void solve()
{
int x=1,y=1;
kkr[2]=kkd[2]=mp(1,1);
while(x!=n||y!=m)
{
if(x<n && s[x+1][y]=='.') ++x;
else ++y;
kkd[x+y]=mp(x,y);
}
x=y=1;
while(x!=n||y!=m)
{
if(y<m && s[x][y+1]=='.') ++y;
else ++x;
kkr[x+y]=mp(x,y);
}
}
void chkmax(int &a,int b)
{
if(b>a) a=b;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m;
F(i,1,n)cin>>s[i]+1;
_1[1][1]=s[1][1]=='.';F(i,1,n)F(j,1,m) if(s[i][j]=='.') _1[i][j]|=_1[i][j-1]|_1[i-1][j];
_2[n][m]=s[n][m]=='.';G(i,n,1)G(j,m,1) if(s[i][j]=='.') _2[i][j]|=_2[i][j+1]|_2[i+1][j];
F(i,1,n)F(j,1,m)if(s[i][j]=='.'&&!(_1[i][j]&&_2[i][j]))s[i][j]='^';
F(i,1,n)F(j,1,m)cnt[i+j]+=s[i][j]=='.',num+=s[i][j]!='*';
if(s[1][1]!='.')
{
cout<<num*(num-1)/2<<'\n';
return 0;
}
F(i,2,n+m) if(cnt[i]==1) ans+=--num;
solve();
G(i,n,1)G(j,m,1)
{
if(s[i][j]!='.') continue;
if(kkd[i+j+1]==mp(i,j+1)) dd[i][j]=i+j+1;
else if(kkr[i+j+1]!=mp(i,j+1))chkmax(dd[i][j],dd[i][j+1]);
if(kkd[i+1+j]==mp(i+1,j)) chkmax(dd[i][j],i+j+1);
else if(kkr[i+j+1]!=mp(i+1,j))chkmax(dd[i][j],dd[i+1][j]);
}
G(i,n,1)G(j,m,1)
{
if(s[i][j]!='.') continue;
if(kkr[i+j+1]==mp(i,j+1)) rr[i][j]=i+j+1;
else if(kkd[i+j+1]!=mp(i,j+1))chkmax(rr[i][j],rr[i][j+1]);
if(kkr[i+1+j]==mp(i+1,j)) chkmax(rr[i][j],i+j+1);
else if(kkd[i+j+1]!=mp(i+1,j))chkmax(rr[i][j],rr[i+1][j]);
}
F(i,1,n+m) ddsum[i]=max(ddsum[i-1],dd[kkd[i].x][kkd[i].y]);
F(i,1,n+m) rrsum[i]=max(rrsum[i-1],rr[kkr[i].x][kkr[i].y]);
F(i,1,n+m) rdsum[i]=max(rdsum[i-1],dd[kkr[i].x][kkr[i].y]);
F(i,1,n+m) drsum[i]=max(drsum[i-1],rr[kkd[i].x][kkd[i].y]);
F(i,2,n+m)
F(j,2,n+m)
{
if(cnt[i]==1 || cnt[j]==1) continue;
// cout<<i<<"-"<<j<<":"<<rdsum[i-1]<<" "<<rrsum[i-1]<<" "<<ddsum[j-1]<<" "<<drsum[j-1]<<'\n';
if(max(rdsum[i-1],ddsum[j-1])>j || max(drsum[j-1],rrsum[i-1])>i) continue;
ans++;
}
cout<<ans<<'\n';
}*/