#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll sum[3001][3001];
ll f(int x1,int y1,int x2,int y2){
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w;cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];
    bool ex[3001][3001];
    memset(ex,false,sizeof ex);
    memset(sum,0,sizeof sum);
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='.')continue;
            int x=i+j+1000;
            int y=j-i+1000;
            sum[x][y]=1;
            ex[x][y]=true;
        }
    }
    rep(i,1,3001){
        rep(j,1,3001){
            sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    ll ans=0;
    ll cnt=0;
    rep(i,0,h){
        rep(j,0,w){
            //cout<<i<<" "<<j<<" "<<ans<<endl;
            if(s[i][j]=='.')continue;
            int x=i+j+1000;
            int y=j-i+1000;
            for(int k=2;k<=602;k+=2){
                //if(i==1&&j==1)cout<<ans<<" ";
                int nx=x,ny=y+k;
                int nex=x+k,ney=y;
                //if(i==1&&j==1&&k==2)cout<<ans<<endl;
                if(ex[nx][ny]){
                    ans+=f(nex,ney+1,nex,ny-1);
                    ans+=f(nx-k,ney+1,nx-k,ny-1);
                    if(ex[nex][ney])cnt++;
                }
                nx=nex,ny=ney;
                nex=x,ney=y-k;
                //if(i==1&&j==1&&k==2)cout<<ans<<endl;
                if(ex[nx][ny]){
                    ans+=f(nex+1,ney,nx-1,ney);
                    ans+=f(nex+1,ney+2*k,nx-1,ny+k);
                    if(ex[nex][ney])cnt++;
                }
                nx=nex,ny=ney;
                nex=x-k,ney=y;
               // if(i==1&&j==1&&k==2)cout<<ans<<endl;
                if(ex[nx][ny]){
                    ans+=f(nex,ny+1,nex,ney-1);
                    ans+=f(nex+2*k,ny+1,nex+2*k,ney-1);
                    if(ex[nex][ney])cnt++;
                }
                nx=nex,ny=ney;
                nex=x,ney=y+k;
                //if(i==1&&j==1&&k==2)cout<<ans<<endl;
                if(ex[nx][ny]){
                    ans+=f(nx+1,ney,nex-1,ney);
                    ans+=f(nx+1,ney-2*k,nex-1,ney-2*k);
                    if(ex[nex][ney])cnt++;
                }
                
            }
        }
    }
    cout<<ans/2+cnt<<endl;
}




Measured memory_bytes: 79488