#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
typedef vector<int> vi;
typedef vector<string> vs;
const int mod = 1000000007;
const int inf = 1061109567;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
signed main()
{
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i,h) cin >> s[i];

    set<pair<int, int> > cur;
    

    int ans = 0;
    for(int i=1; i<h-1; i++){
        int j = 1;
        int a = 1, b = w-1;
        bool check = false;
        set<pair<int, int> > now;
        while(1){
            if(s[i][j] == '#'){
                if(check) b = j;
                else{
                    a = j;
                    b = j;
                    check = true;
                }
            }
            else{
                if(check){
                    int plus = 4;
                    for(auto u : cur){
                        if(u.first == a && u.second == b) plus = 0;
                        else if(u.first == a || u.second == b) plus -= 2;
                    }
                    //cout << plus << endl;
                    ans += plus;
                    now.insert(make_pair(a, b));
                    check = false;
                }
            }
            j++;
            if(j == w) break;
        }
        //for(auto u : now) cout << u.first << ' ' << u.second << endl;
        cur = now;
    }
    
    cout << ans << endl;



    return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
#define all(v) (v).begin(),(v).end()
#define MAXN 300005
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime));
    prime[0]=prime[1]=0;
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[1000010];
ll finv[1000010];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return 0;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int te=1;
    //cin>>te;
    //SieveOfEratosthenes(1000000);
    //factorial(1000005);
    while(te--){
        int h,w;
        cin>>h>>w;
        string a[h];
        for(int i=0;i<h;i++)
            cin>>a[i];
        int ans=0;
        for(int i=1;i<h-1;i++){
            for(int j=1;j<w-1;j++){
                if(a[i][j]=='.')
                    continue;
                if(a[i][j-1]=='.'&&a[i-1][j]=='.')
                    ans++;
                if(a[i][j+1]=='.'&&a[i-1][j]=='.')
                    ans++;
                if(a[i][j-1]=='.'&&a[i+1][j]=='.')
                    ans++;
                if(a[i][j+1]=='.'&&a[i+1][j]=='.')
                    ans++;
                if(a[i][j-1]=='#'&&a[i-1][j]=='#'&&a[i-1][j-1]=='.')
                    ans++;
                if(a[i][j+1]=='#'&&a[i-1][j]=='#'&&a[i-1][j+1]=='.')
                    ans++;
                if(a[i][j-1]=='#'&&a[i+1][j]=='#'&&a[i+1][j-1]=='.')
                    ans++;
                if(a[i][j+1]=='#'&&a[i+1][j]=='#'&&a[i+1][j+1]=='.')
                    ans++;
            }
        }
        cout<<ans;
    }
}