#include<bits/stdc++.h>
#define LL long long
using namespace std;

int n,m;
char w[2005][2005];

int subsetLR[2005] = {0},subsetRL[2005] = {0},subsetTB[2005] = {0},subsetBT[2005] = {0};
int lengthLR[2005][2005]={0} , lengthRL[2005][2005]={0},lengthTB[2005][2005]={0},lengthBT[2005][2005]={0};
int bitLR[2005][2005] = {0}, bitRL[2005][2005] = {0},bitTB[2005][2005] = {0},bitBT[2005][2005] = {0};
LL ans0 = 0, ans1 = 0, ans2 = 0;

void fillSubset(){
    for(int i=0; i<n;i++){
        int cnt = 0;
        for(int j=0; j<m;j++){
            if(w[i][j] == '.') cnt++;
            else break;
        }
        subsetLR[i] = cnt;
        cnt = 0;
        for(int j=m-1; j>=0; j--){
            if(w[i][j] == '.') cnt++;
            else break;
        }
        subsetRL[i] = cnt;
    }

    for(int j=0; j<m;j++){
        int cnt = 0;
        for(int i=0; i<n;i++){
            if(w[i][j] == '.') cnt++;
            else break;
        }
        subsetTB[j] = cnt;
        cnt = 0;
        for(int i=n-1; i>=0; i--){
            if(w[i][j] == '.') cnt++;
            else break;
        }
        subsetBT[j] = cnt;
    }
}

void fillLength(){
    for(int i=0; i<n; i++){
        int cnt = 0;
        for(int j=0; j<m;j++){
            if(w[i][j] == '.') cnt++;
            else cnt = 0;
            lengthLR[i][j] = cnt;
        }
        cnt = 0;
        for(int j=m-1; j>=0; j--){
            if(w[i][j] == '.') cnt++;
            else cnt = 0;
            lengthRL[i][j] = cnt;

        }
    }

    for(int j=0; j<m;j++){
        int cnt = 0;
        for(int i=0; i<n;i++){
            if(w[i][j] == '.') cnt++;
            else cnt = 0;
            lengthTB[i][j] = cnt;
        }
        cnt = 0;
        for(int i=n-1; i>=0; i--){
            if(w[i][j] == '.') cnt++;
            else cnt = 0;
            lengthBT[i][j] = cnt;
        }
    }
}

void fillBIT(){
    for(int i=0; i<n;i++){
        int v = subsetLR[i];
        for(int j=v; j;j--){
            for(int k=i+1; k<2005;k+=(k&-k)){
                bitLR[k][j]++;
            }
        }

        v = subsetRL[i];
        for(int j=v; j;j--){
            for(int k=i+1; k<2005;k+=(k&-k)){
                bitRL[k][j]++;
            }
        }
    }

    for(int j=0; j<m;j++){
        int v = subsetTB[j];
        for(int i=v; i;i--){
            for(int k=j+1; k<2005;k+=(k&-k)){
                bitTB[k][i]++;
            }
        }

        v = subsetBT[j];
        for(int i=v; i;i--){
            for(int k=j+1; k<2005;k+=(k&-k)){
                bitBT[k][i]++;
            }
        }
    }
}

int sum(int x,int v, int t){
    int ret = 0;
    for(int i=x; i; i-= (i&-i)){
        if(t==0) ret += bitLR[i][v];
        if(t==1) ret += bitRL[i][v];
        if(t==2) ret += bitTB[i][v];
        if(t==3) ret += bitBT[i][v];
    }
    return ret;
}

int query(int x, int y, int v, int t){
    return sum(y+1,v,t) - sum(x, v, t);
}

void precompute(){
    fillSubset();
    fillLength();
    fillBIT();
}

void fillAns0(){
    for(int i=1; i<n-1; i++){
        bool ok = true;
        for(int j=0; j<m;j++) ok &= w[i][j] == '.';
        ans0 += ok;
    }

    for(int j=1; j<m-1;j++){
        bool ok = true;
        for(int i=0; i<n;i++) ok &= w[i][j] == '.';
        ans0 += ok;
    }
}

void fillAns1(){
    for(int i=1; i<n-1; i++){
        for(int j=1; j<m-1;j++){
            ans1 += (subsetLR[i] >= j+1 && subsetTB[j] >= i+1);
            ans1 += (subsetRL[i] >= m-j && subsetTB[j] >= i+1);
            ans1 += (subsetLR[i] >= j+1 && subsetBT[j] >= n-i);
            ans1 += (subsetRL[i] >= m-j && subsetBT[j] >= n-i);
        }
    }
}

void fillAns2(){
    for(int i=1; i<n-1; i++){
        for(int j=1; j<m-1; j++){
            if(subsetLR[i] >= j+1){
                if(i-lengthTB[i][j]+1 > 0 && i-lengthTB[i][j]+1 <= i-2){
                    ans2 += query(i-lengthTB[i][j]+1, i-2, j+1, 0);
                }
                if(i-lengthTB[i][j]+1 > 0 && i-lengthTB[i][j]+1 <= i-1){
                    ans2 += query(i-lengthTB[i][j]+1, i-1, m-j, 1);
                }
            }
            if(subsetRL[i] >= m-j){
                if(i-lengthTB[i][j]+1 > 0 && i-lengthTB[i][j]+1 <= i-2){
                    ans2 += query(i-lengthTB[i][j]+1, i-2, m-j, 1);
                }
                if(i-lengthTB[i][j]+1 > 0 && i-lengthTB[i][j]+1 <= i-1){
                    ans2 += query(i-lengthTB[i][j]+1, i-1, j+1, 0);
                }
            }
        }
    }
    for(int j=1; j<m-1;j++){
        for(int i=1; i<n-1;i++){
            if(subsetTB[j] >= i+1){
                if(j-lengthLR[i][j]+1 > 0 && j-lengthLR[i][j]+1 <= j-2){
                    ans2 += query(j-lengthLR[i][j]+1, j-2, i+1, 2);
                }
                if(j-lengthLR[i][j]+1 > 0 && j-lengthLR[i][j]+1 <= j-1){
                    ans2 += query(j-lengthLR[i][j]+1, j-1, n-i, 3);
                }
            }
            if(subsetBT[j] >= n-i){
                if(j-lengthLR[i][j]+1 > 0 && j-lengthLR[i][j]+1 <= j-2){
                    ans2 += query(j-lengthLR[i][j]+1, j-2, n-i, 3);
                }
                if(j-lengthLR[i][j]+1 > 0 && j-lengthLR[i][j]+1 <= j-1){
                    ans2 += query(j-lengthLR[i][j]+1, j-1, i+1, 2);
                }
            }
        }
    }
}

int main(){
    scanf("%d%d", &n,&m);
    for(int i=0; i<n;i++)scanf("%s", w[i]);

    precompute();

//    printf("%I64d %I64d %I64d\n", ans0, ans1, ans2);
    fillAns0();
//    printf("%I64d %I64d %I64d\n", ans0, ans1, ans2);
    fillAns1();
//    printf("%I64d %I64d %I64d\n", ans0, ans1, ans2);
    fillAns2();
//    printf("%I64d %I64d %I64d\n", ans0, ans1, ans2);
    printf("%I64d\n", ans0 + ans1 + ans2);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000 + 10;

int n, m;
char board[MAXN][MAXN];

bool l[MAXN][MAXN], r[MAXN][MAXN], u[MAXN][MAXN], d[MAXN][MAXN];
int hu[MAXN][MAXN], hd[MAXN][MAXN], vl[MAXN][MAXN], vr[MAXN][MAXN];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", board[i]);
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            u[i][j] = board[i][j] != '#';
            if (i > 0) {
                u[i][j] &= u[i - 1][j];
            }
            l[i][j] = board[i][j] != '#';
            if (j > 0) {
                l[i][j] &= l[i][j - 1];
            }
        }
    }
    for (int i = n - 1; i >= 0; --i) {
        for (int j = m - 1; j >= 0; --j) {
            d[i][j] = board[i][j] != '#';
            if (i < n - 1) {
                d[i][j] &= d[i + 1][j];
            }
            r[i][j] = board[i][j] != '#';
            if (j < m - 1) {
                r[i][j] &= r[i][j + 1];
            }
        }
    }
    for (int i = 1; i < n - 1; ++i) {
        int start = -1, cntU = 0, cntD = 0;
        for (int j = 1; j < m; ++j) {
            if (j == m - 1 || board[i][j] == '#') {
                if (start != -1) {
                    for (int k = start; k < j; ++k) {
                        hu[i][k] = cntU;
                        hd[i][k] = cntD;
                    }
                    start = -1;
                    cntU = 0;
                    cntD = 0;
                }
            } else {
                if (start == -1) {
                    start = j;
                }
                cntU += u[i][j];
                cntD += d[i][j];
            }
        }
    }
    for (int j = 1; j < m - 1; ++j) {
        int start = -1, cntL = 0, cntR = 0;
        for (int i = 1; i < n; ++i) {
            if (i == n - 1 || board[i][j] == '#') {
                if (start != -1) {
                    for (int k = start; k < i; ++k) {
                        vl[k][j] = cntL;
                        vr[k][j] = cntR;
                    }
                    start = -1;
                    cntL = 0;
                    cntR = 0;
                }
            } else {
                if (start == -1) {
                    start = i;
                }
                cntL += l[i][j];
                cntR += r[i][j];
            }
        }
    }
    long long turn0 = 0;
    for (int i = 1; i < n - 1; ++i) {
        turn0 += r[i][0];
    }
    for (int j = 1; j < m - 1; ++j) {
        turn0 += d[0][j];
    }
    long long turn1 = 0;
    for (int i = 1; i < n - 1; ++i) {
        for (int j = 1; j < m - 1; ++j) {
            turn1 += l[i][j] && u[i][j];
            turn1 += u[i][j] && r[i][j];
            turn1 += r[i][j] && d[i][j];
            turn1 += d[i][j] && l[i][j];
        }
    }
    long long turn2 = 0;
    for (int i = 0; i < n; ++i) {
        u[i][0] = d[i][0] = l[i][0] = r[i][0] = 0;
        u[i][m - 1] = d[i][m - 1] = l[i][m - 1] = r[i][m - 1] = 0;
    }
    for (int j = 0; j < m; ++j) {
        u[0][j] = d[0][j] = l[0][j] = r[0][j] = 0;
        u[n - 1][j] = d[n - 1][j] = l[n - 1][j] = r[n - 1][j] = 0;
    }
    for (int i = 1; i < n - 1; ++i) {
        for (int j = 1; j < m - 1; ++j) {
            if (u[i][j]) {
                if (hu[i][j]) {
                    turn2 += hu[i][j] - u[i][j] - u[i][j - 1] - u[i][j + 1];
                }
                if (hd[i][j]) {
                    turn2 += hd[i][j] - d[i][j];
                }
            }
            if (d[i][j]) {
                if (hd[i][j]) {
                    turn2 += hd[i][j] - d[i][j] - d[i][j - 1] - d[i][j + 1];
                }
                if (hu[i][j]) {
                    turn2 += hu[i][j] - u[i][j];
                }
            }
            if (l[i][j]) {
                if (vl[i][j]) {
                    turn2 += vl[i][j] - l[i][j] - l[i - 1][j] - l[i + 1][j];
                }
                if (vr[i][j]) {
                    turn2 += vr[i][j] - r[i][j];
                }
            }
            if (r[i][j]) {
                if (vr[i][j]) {
                    turn2 += vr[i][j] - r[i][j] - r[i - 1][j] - r[i + 1][j];
                }
                if (vl[i][j]) {
                    turn2 += vl[i][j] - l[i][j];
                }
            }
        }
    }
    turn2 >>= 1;
    cout << turn0 + turn1 + turn2 << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <assert.h>
#include <map>
#include <set>
using namespace std;

const int N = 2010;
char s[N][N], str[N][N];
long long ans;
bool up[N][N], down[N][N];

void solve(char s[N][N], int n, int m, bool flag) {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
	        if (s[i][j] == '#') {
				up[i][j] = true;
				continue;
			}
			if (i == 1) up[i][j] = false;
			else up[i][j] |= up[i - 1][j];
		}
	}

	for (int i = n; i >= 1; i--)
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '#') down[i][j] = true;
			else if (i == n) down[i][j] = false;
			else down[i][j] |= down[i + 1][j];

    for (int i = 2; i < n; i++) {
		bool flag = false;
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '#') flag = true;
		ans += !flag;
	}

	// count two turn
	//  |_|
	for (int i = 2; i < n; i++) {
		int cnt_up = 0, cnt_down = 0;
		for (int j = 3; j < m; j++) {
			if (s[i][j] == '#') {
				cnt_up = 0;
				cnt_down = 0;
				continue;
			}
			if (!up[i][j]) ans += cnt_up;
			if (!down[i][j]) ans += cnt_down;
			cnt_up += !up[i][j - 1];
			cnt_down += !down[i][j - 1];

		}
	}
	//  |_
	//    |
	for (int i = 2; i < n; i++) {
		int cnt_up = 0, cnt_down = 0;
		for (int j = 2; j < m; j++) {
			if (s[i][j] == '#') {
				cnt_up = 0;
				cnt_down = 0;
				continue;
			}
			if (!up[i][j]) ans += cnt_down;
			if (!down[i][j]) ans += cnt_up;
			cnt_up += !up[i][j];
			cnt_down += !down[i][j];
		}
	}

	// count one turn
	if (!flag) return;
	for (int i = 2; i < n; i++) {
	    for (int j = 1; j < m; j++) {
			if (s[i][j] == '#') break;
			if (j > 1) ans += !up[i][j];
			if (j > 1) ans += !down[i][j];
		}
		for (int j = m; j > 1; j--) {
			if (s[i][j] == '#') break;
			if (j < m) ans += !up[i][j];
			if (j < m) ans += !down[i][j];
		}
	}
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%s", s[i] + 1);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			str[j][i] = s[i][j];

	solve(s, n, m, true);

	solve(str, m, n, false);
    cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <assert.h>
#include <map>
#include <set>
using namespace std;

const int N = 2010;
char s[N][N], str[N][N];
long long ans;
bool up[N][N], down[N][N];

void solve(char s[N][N], int n, int m, bool flag) {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
	        if (s[i][j] == '#') {
				up[i][j] = true;
				continue;
			}
			if (i == 1) up[i][j] = false;
			else up[i][j] = up[i - 1][j];
		}
	}

	for (int i = n; i >= 1; i--)
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '#') down[i][j] = true;
			else if (i == n) down[i][j] = false;
			else down[i][j] = down[i + 1][j];

    for (int i = 2; i < n; i++) {
		bool flag = false;
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '#') flag = true;
		ans += !flag;
	}

	// count two turn
	//  |_|
	for (int i = 2; i < n; i++) {
		int cnt_up = 0, cnt_down = 0;
		for (int j = 3; j < m; j++) {
			if (s[i][j] == '#') {
				cnt_up = 0;
				cnt_down = 0;
				continue;
			}
			if (!up[i][j]) ans += cnt_up;
			if (!down[i][j]) ans += cnt_down;
			cnt_up += !up[i][j - 1];
			cnt_down += !down[i][j - 1];

		}
	}
	//  |_
	//    |
	for (int i = 2; i < n; i++) {
		int cnt_up = 0, cnt_down = 0;
		for (int j = 2; j < m; j++) {
			if (s[i][j] == '#') {
				cnt_up = 0;
				cnt_down = 0;
				continue;
			}
			if (!up[i][j]) ans += cnt_down;
			if (!down[i][j]) ans += cnt_up;
			cnt_up += !up[i][j];
			cnt_down += !down[i][j];
		}
	}

	// count one turn
	if (!flag) return;
	for (int i = 2; i < n; i++) {
	    for (int j = 1; j < m; j++) {
			if (s[i][j] == '#') break;
			if (j > 1) ans += !up[i][j];
			if (j > 1) ans += !down[i][j];
		}
		for (int j = m; j > 1; j--) {
			if (s[i][j] == '#') break;
			if (j < m) ans += !up[i][j];
			if (j < m) ans += !down[i][j];
		}
	}
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%s", s[i] + 1);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			str[j][i] = s[i][j];

	solve(s, n, m, true);

	solve(str, m, n, false);
    cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <assert.h>
#include <map>
#include <set>
using namespace std;

const int N = 2010;
char s[N][N], str[N][N];
long long ans;
bool up[N][N], down[N][N];

void solve(char s[N][N], int n, int m, bool flag) {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
	        if (s[i][j] == '#') {
				up[i][j] = true;
				continue;
			}
			if (i == 1) up[i][j] = false;
			else up[i][j] |= up[i - 1][j];
		}
	}

	for (int i = n; i >= 1; i--)
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '#') down[i][j] = true;
			else if (i == n) down[i][j] = false;
			else down[i][j] |= down[i + 1][j];

    for (int i = 2; i < n; i++) {
		bool flag = false;
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '#') flag = true;
		ans += !flag;
	}

	// count two turn
	//  |_|
	for (int i = 2; i < n; i++) {
		int cnt_up = 0, cnt_down = 0;
		for (int j = 3; j < m; j++) {
			if (s[i][j] == '#') {
				cnt_up = 0;
				cnt_down = 0;
				continue;
			}
			if (!up[i][j]) ans += cnt_up;
			if (!down[i][j]) ans += cnt_down;
			cnt_up += !up[i][j - 1];
			cnt_down += !down[i][j - 1];

		}
	}
	//  |_
	//    |
	for (int i = 2; i < n; i++) {
		int cnt_up = 0, cnt_down = 0;
		for (int j = 2; j < m; j++) {
			if (s[i][j] == '#') {
				cnt_up = 0;
				cnt_down = 0;
				continue;
			}
			if (!up[i][j]) ans += cnt_down;
			if (!down[i][j]) ans += cnt_up;
			cnt_up += !up[i][j];
			cnt_down += !down[i][j];
		}
	}

	// count one turn
	if (!flag) return;
	for (int i = 2; i < n; i++) {
	    for (int j = 1; j < m; j++) {
			if (s[i][j] == '#') break;
			if (j > 1) ans += !up[i][j];
			if (j > 1) ans += !down[i][j];
		}
		for (int j = m; j > 1; j--) {
			if (s[i][j] == '#') break;
			if (j > 1) ans += !up[i][j];
			if (j > 1) ans += !down[i][j];
		}
	}
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%s", s[i] + 1);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			str[j][i] = s[i][j];

	solve(s, n, m, true);

	solve(str, m, n, false);
    cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int MAXN = 2005;
char s[MAXN][MAXN];
int r[MAXN][2];
int c[MAXN][2];
int lr[MAXN][MAXN];
int ans;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);

    for(int i=2;i<n;i++){
        r[i][0]=m;
        for(int j=1;j<=m;j++)
            if(s[i][j]=='#'){
                r[i][0]=j-1;
                break;
            }
        r[i][1]=1;
        for(int j=m;j>=1;j--)
        if(s[i][j]=='#'){
            r[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<m;i++){
        c[i][0]=n;
        for(int j=1;j<=n;j++)
            if(s[j][i]=='#'){
                c[i][0]=j-1;
                break;
            }
        c[i][1]=1;
        for(int j=n;j>=1;j--)
        if(s[j][i]=='#'){
            c[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<n;i++)
    for(int j=2;j<m;j++){
        int v1=0;
        int v2=0;
        if(r[i][0]>=j)v1++;
        if(r[i][1]<=j)v1++;
        if(c[j][0]>=i)v2++;
        if(c[j][1]<=i)v2++;
        ans+=v1*v2;
    }
    for(int i=2;i<n;i++)if(r[i][0]>=m)ans++;
    for(int i=2;i<m;i++)if(c[i][0]>=n)ans++;
    for(int i=2;i<n;i++){
        memset(lr,0,sizeof(lr));
        for(int l=m-1;l>1;l--)
        for(int r=l;r<m;r++){
            if(s[i][l]=='#')continue;
            if(l==r){
                lr[l][l]=1;
                continue;
            }
            else lr[l][r]=lr[l+1][r];
            if(lr[l][r]==0)continue;

            if(c[l][0]>=i&&c[r][1]<=i)ans++;
            if(c[r][0]>=i&&c[l][1]<=i)ans++;
            if(l+1!=r){
            if(c[l][0]>=i&&c[r][0]>=i)ans++;
            if(c[r][1]<=i&&c[l][1]<=i)ans++;
            }
        }
    }

    for(int i=2;i<m;i++){
        memset(lr,0,sizeof(lr));
        for(int l=n-1;l>1;l--)
        for(int rr=l;rr<n;rr++){
            if(s[l][i]=='#')continue;
            if(l==rr){
                lr[l][l]=1;
                continue;
            }
            else lr[l][rr]=lr[l+1][rr];
            if(lr[l][rr]==0)continue;

            if(r[l][0]>=i&&r[rr][1]<=i)ans++;
            if(r[rr][0]>=i&&r[l][1]<=i)ans++;
            if(l+1!=rr){
            if(r[l][0]>=i&&r[rr][0]>=i)ans++;
            if(r[rr][1]<=i&&r[l][1]<=i)ans++;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int MAXN = 2005;
char s[MAXN][MAXN];
int r[MAXN][2];
int c[MAXN][2];
int ans;

int main()
{
    for(int i=1;i<=2000;i++)
        for(int j=1;j<=2000;j++)
        for(int k=1;k<=2000;k++)ans=ans*1;
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    for(int i=2;i<n;i++){
        r[i][0]=m;
        for(int j=1;j<=m;j++)
            if(s[i][j]=='#'){
                r[i][0]=j-1;
                break;
            }
        r[i][1]=1;
        for(int j=m;j>=1;j--)
        if(s[i][j]=='#'){
            r[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<m;i++){
        c[i][0]=n;
        for(int j=1;j<=n;j++)
            if(s[j][i]=='#'){
                c[i][0]=j-1;
                break;
            }
        c[i][1]=1;
        for(int j=n;j>=1;j--)
        if(s[j][i]=='#'){
            c[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<n;i++)
    for(int j=2;j<m;j++){
        int v1=0;
        int v2=0;
        if(r[i][0]>=j)v1++;
        if(r[i][1]<=j)v1++;
        if(c[j][0]>=i)v2++;
        if(c[j][1]<=i)v2++;
        ans+=v1*v2;
    }
    for(int i=2;i<m;i++)
    for(int j=i;j<n;j++){

    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int MAXN = 2005;
char s[MAXN][MAXN];
int r[MAXN][2];
int c[MAXN][2];
int ans;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);

    for(int i=1;i<=2000;i++)
        for(int j=1;j<=2000;j++)
        for(int k=1;k<=2000;k++)ans++;

    for(int i=2;i<n;i++){
        r[i][0]=m;
        for(int j=1;j<=m;j++)
            if(s[i][j]=='#'){
                r[i][0]=j-1;
                break;
            }
        r[i][1]=1;
        for(int j=m;j>=1;j--)
        if(s[i][j]=='#'){
            r[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<m;i++){
        c[i][0]=n;
        for(int j=1;j<=n;j++)
            if(s[j][i]=='#'){
                c[i][0]=j-1;
                break;
            }
        c[i][1]=1;
        for(int j=n;j>=1;j--)
        if(s[j][i]=='#'){
            c[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<n;i++)
    for(int j=2;j<m;j++){
        int v1=0;
        int v2=0;
        if(r[i][0]>=j)v1++;
        if(r[i][1]<=j)v1++;
        if(c[j][0]>=i)v2++;
        if(c[j][1]<=i)v2++;
        ans+=v1*v2;
    }
    for(int i=2;i<m;i++)
    for(int j=i;j<n;j++){

    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int MAXN = 2005;
char s[MAXN][MAXN];
int r[MAXN][2];
int c[MAXN][2];
int ans;

int main()
{
    for(int i=1;i<=2000;i++)
        for(int j=1;j<=2000;j++)
        for(int k=1;k<=2000;k++)ans++;
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    for(int i=2;i<n;i++){
        r[i][0]=m;
        for(int j=1;j<=m;j++)
            if(s[i][j]=='#'){
                r[i][0]=j-1;
                break;
            }
        r[i][1]=1;
        for(int j=m;j>=1;j--)
        if(s[i][j]=='#'){
            r[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<m;i++){
        c[i][0]=n;
        for(int j=1;j<=n;j++)
            if(s[j][i]=='#'){
                c[i][0]=j-1;
                break;
            }
        c[i][1]=1;
        for(int j=n;j>=1;j--)
        if(s[j][i]=='#'){
            c[i][1]=j+1;
            break;
        }
    }
    for(int i=2;i<n;i++)
    for(int j=2;j<m;j++){
        int v1=0;
        int v2=0;
        if(r[i][0]>=j)v1++;
        if(r[i][1]<=j)v1++;
        if(c[j][0]>=i)v2++;
        if(c[j][1]<=i)v2++;
        ans+=v1*v2;
    }
    for(int i=2;i<m;i++)
    for(int j=i;j<n;j++){

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define F first
#define S second
#define lson (o<<1),l,mid
#define rson (o<<1|1),mid+1,r
const int inf = 0x3f3f3f3f ;
const ll INF = (ll)1e18 ;

const int M = 2000+10 ;
int sumh[M][M] , sumv[M][M] ;
char s[M][M] ;
int n , m ;
ll ans[3] ;

ll get_turn0 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
	   	if (sumh[i][m] == 0) ret ++ ;
	}
	for (int i = 2 ; i <= m-1 ; i ++) {
		if (sumv[n][i] == 0) ret ++ ;
	}
	return ret ;
}

ll get_turn1 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		for (int j = 2 ; j <= m-1 ; j ++) {
			if (!sumh[i][j]&&!sumv[i][j]) ret ++ ;
			if (!sumh[i][j]&&!(sumv[n][j]-sumv[i-1][j])) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!sumv[i][j]) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!(sumv[n][j]-sumv[i-1][j]))ret++;
		}
	}
	return ret ;
}

ll get_turn2 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2]={} ;
		for (int j = 2 ; j <= m ; j ++) {
			if (s[i][j]=='#' || j==m) {
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				last[0] = last[1] = two = one = des = 0 ;
				continue ;
			}
			if (!sumv[i][j]&&!(sumv[n][j]-sumv[i-1][j])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumv[i][j]) {
				one ++ ;
				if (last[0]) des ++ ;
				last[0] = 1 , last[1] = 0 ;
			}
			else if (!(sumv[n][j]-sumv[i-1][j])) {
				one ++ ;
				if (last[1]) des ++ ;
				last[0] = 0 , last[1] = 1 ;
			}
		}
	}
	//printf ("ret="LLD"\n",ret) ;
	for (int i = 2 ; i <= m-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2] = {} ;
		for (int j = 2 ; j <= n ; j ++) {
			if (s[j][i]=='#' || j==n) {
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				last[0] = last[1] = des = two = one = 0 ;
				continue ;
			}
			if (!sumh[j][i]&&!(sumh[j][m]-sumh[j][i-1])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumh[j][i]) {
				one++ ;
				if (last[0]) des ++ ;
				last[0]=1 , last[1]=0 ;
			}
			else if (!(sumh[j][m]-sumh[j][i-1])) {
				one++ ;
				if (last[1]) des ++ ;
				last[0]=0 , last[1]=1 ;
			}
		}
	}
	//printf ("ret="LLD"\n",ret) ;
	return ret ;
}

int main () {
	cin >> n >> m ;
	for (int i = 1 ; i <= n ; i ++) scanf ("%s" , s[i]+1) ;
	for (int i = 1 ; i <= n ; i ++) {
		for (int j = 1 ; j <= m ; j ++) {
			sumh[i][j] = sumh[i][j-1] + (s[i][j]=='#'?1:0) ;
			sumv[i][j] = sumv[i-1][j] + (s[i][j]=='#'?1:0) ;
		}
	}

	ans[0] = get_turn0() ;
	ans[1] = get_turn1() ;
	ans[2] = get_turn2() ;
	//for (int i = 0 ; i < 3 ; i ++) printf ("ans[%d]="LLD"\n" ,i , ans[i]) ;
	printf(LLD,ans[0]+ans[1]+ans[2]) ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define F first
#define S second
#define lson (o<<1),l,mid
#define rson (o<<1|1),mid+1,r
const int inf = 0x3f3f3f3f ;
const ll INF = (ll)1e18 ;

const int M = 2000+10 ;
int sumh[M][M] , sumv[M][M] ;
char s[M][M] ;
int n , m ;
ll ans[3] ;

ll get_turn0 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
	   	if (sumh[i][m] == 0) ret ++ ;
	}
	for (int i = 2 ; i <= m-1 ; i ++) {
		if (sumv[n][i] == 0) ret ++ ;
	}
	return ret ;
}

ll get_turn1 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		for (int j = 2 ; j <= m-1 ; j ++) {
			if (!sumh[i][j]&&!sumv[i][j]) ret ++ ;
			if (!sumh[i][j]&&!(sumv[n][j]-sumv[i-1][j])) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!sumv[i][j]) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!(sumv[n][j]-sumv[i-1][j]))ret++;
		}
	}
	return ret ;
}

ll get_turn2 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2]={} ;
		for (int j = 2 ; j <= m ; j ++) {
			if (s[i][j]=='#' || j==m) {
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				last[0] = last[1] = two = one = des = 0 ;
				continue ;
			}
			if (!sumv[i][j]&&!(sumv[n][j]-sumv[i-1][j])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumv[i][j]) {
				one ++ ;
				if (last[0]) des ++ ;
				last[0] = 1 , last[1] = 0 ;
			}
			else if (!(sumv[n][j]-sumv[i-1][j])) {
				one ++ ;
				if (last[1]) des ++ ;
				last[0] = 0 , last[1] = 1 ;
			}
		}
	}
	//printf ("ret="LLD"\n",ret) ;
	for (int i = 2 ; i <= m-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2] = {} ;
		for (int j = 2 ; j <= n ; j ++) {
			if (s[i][j]=='#' || j==n) {
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				last[0] = last[1] = des = two = one = 0 ;
				continue ;
			}
			if (!sumh[j][i]&&!(sumh[j][m]-sumh[j][i-1])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumh[j][i]) {
				one++ ;
				if (last[0]) des ++ ;
				last[0]=1 , last[1]=0 ;
			}
			else if (!(sumh[j][m]-sumh[j][i-1])) {
				one++ ;
				if (last[1]) des ++ ;
				last[0]=0 , last[1]=1 ;
			}
		}
	}
	//printf ("ret="LLD"\n",ret) ;
	return ret ;
}

int main () {
	cin >> n >> m ;
	for (int i = 1 ; i <= n ; i ++) scanf ("%s" , s[i]+1) ;
	for (int i = 1 ; i <= n ; i ++) {
		for (int j = 1 ; j <= m ; j ++) {
			sumh[i][j] = sumh[i][j-1] + (s[i][j]=='#'?1:0) ;
			sumv[i][j] = sumv[i-1][j] + (s[i][j]=='#'?1:0) ;
		}
	}

	ans[0] = get_turn0() ;
	ans[1] = get_turn1() ;
	ans[2] = get_turn2() ;
	//for (int i = 0 ; i < 3 ; i ++) printf ("ans[%d]="LLD"\n" ,i , ans[i]) ;
	printf(LLD,ans[0]+ans[1]+ans[2]) ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define F first
#define S second
#define lson (o<<1),l,mid
#define rson (o<<1|1),mid+1,r
const int inf = 0x3f3f3f3f ;
const ll INF = (ll)1e18 ;

const int M = 2000+10 ;
int sumh[M][M] , sumv[M][M] ;
char s[M][M] ;
int n , m ;
ll ans[3] ;

ll get_turn0 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
	   	if (sumh[i][m] == 0) ret ++ ;
	}
	for (int i = 2 ; i <= m-1 ; i ++) {
		if (sumv[n][i] == 0) ret ++ ;
	}
	return ret ;
}

ll get_turn1 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		for (int j = 2 ; j <= m-1 ; j ++) {
			if (!sumh[i][j]&&!sumv[i][j]) ret ++ ;
			if (!sumh[i][j]&&!(sumv[n][j]-sumv[i-1][j])) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!sumv[i][j]) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!(sumv[n][j]-sumv[i-1][j]))ret++;
		}
	}
	return ret ;
}

ll get_turn2 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2]={} ;
		for (int j = 2 ; j <= m ; j ++) {
			if (s[i][j]=='#' || j==m) {
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				last[0] = last[1] = two = one = des = 0 ;
				continue ;
			}
			if (!sumv[i][j]&&!(sumv[n][j]-sumv[i-1][j])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumv[i][j]) {
				one ++ ;
				if (last[0]) des ++ ;
				last[0] = 1 , last[1] = 0 ;
			}
			else if (!(sumv[n][j]-sumv[i-1][j])) {
				one ++ ;
				if (last[1]) des ++ ;
				last[0] = 0 , last[1] = 1 ;
			}
		}
	}
	for (int i = 2 ; i <= m-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2] = {} ;
		for (int j = 2 ; j <= n ; j ++) {
			if (s[i][j]=='#' || j==n) {
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				two = one = 0 ;
				continue ;
			}
			if (!sumh[i][j]&&!(sumh[j][m]-sumh[j][i-1])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumh[i][j]) {
				one++ ;
				if (last[0]) des ++ ;
				last[0]=1 , last[1]=0 ;
			}
			else if (!(sumh[j][m]-sumh[j][i-1])) {
				one++ ;
				if (last[1]) des ++ ;
				last[0]=0 , last[1]=1 ;
			}
		}
	}
	return ret ;
}

int main () {
	cin >> n >> m ;
	for (int i = 1 ; i <= n ; i ++) scanf ("%s" , s[i]+1) ;
	for (int i = 1 ; i <= n ; i ++) {
		for (int j = 1 ; j <= m ; j ++) {
			sumh[i][j] = sumh[i][j-1] + (s[i][j]=='#'?1:0) ;
			sumv[i][j] = sumv[i-1][j] + (s[i][j]=='#'?1:0) ;
		}
	}

	ans[0] = get_turn0() ;
	ans[1] = get_turn1() ;
	ans[2] = get_turn2() ;
	//for (int i = 0 ; i < 3 ; i ++) printf ("ans[%d]="LLD"\n" ,i , ans[i]) ;
	printf(LLD,ans[0]+ans[1]+ans[2]) ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define F first
#define S second
#define lson (o<<1),l,mid
#define rson (o<<1|1),mid+1,r
const int inf = 0x3f3f3f3f ;
const ll INF = (ll)1e18 ;

const int M = 2000+10 ;
int sumh[M][M] , sumv[M][M] ;
char s[M][M] ;
int n , m ;
ll ans[3] ;

ll get_turn0 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
	   	if (sumh[i][m] == 0) ret ++ ;
	}
	for (int i = 2 ; i <= m-1 ; i ++) {
		if (sumv[n][i] == 0) ret ++ ;
	}
	return ret ;
}

ll get_turn1 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		for (int j = 2 ; j <= m-1 ; j ++) {
			if (!sumh[i][j]&&!sumv[i][j]) ret ++ ;
			if (!sumh[i][j]&&!(sumv[n][j]-sumv[i-1][j])) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!sumv[i][j]) ret ++ ;
			if (!(sumh[i][m]-sumh[i][j-1])&&!(sumv[n][j]-sumv[i-1][j]))ret++;
		}
	}
	return ret ;
}

ll get_turn2 () {
	ll ret = 0 ;
	for (int i = 2 ; i <= n-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2]={} ;
		//puts ("-----------") ;
		for (int j = 2 ; j <= m ; j ++) {
			if (s[i][j]=='#' || j==m) {
				//printf ("two=%d,one=%d,des=%d\n" , two,one,des) ;
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				//cout << "change = " << 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two - 1ll*des << endl ;
				last[0] = last[1] = two = one = des = 0 ;
				continue ;
			}
			if (!sumv[i][j]&&!(sumv[n][j]-sumv[i-1][j])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumv[i][j]) {
				one ++ ;
				if (last[0]) des ++ ;
				last[0] = 1 , last[1] = 0 ;
			}
			else if (!(sumv[n][j]-sumv[i-1][j])) {
				one ++ ;
				if (last[1]) des ++ ;
				last[0] = 0 , last[1] = 1 ;
			}
			else last[0]=last[1]=0 ;
		}
	}
	//puts ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^") ;
	//printf ("ret="LLD"\n",ret) ;
	for (int i = 2 ; i <= m-1 ; i ++) {
		int two = 0 , one = 0 ;
		int des = 0 ;
		bool last[2] = {} ;
		//puts ("-------------------------------------------") ;
		for (int j = 2 ; j <= n ; j ++) {
			if (s[j][i]=='#' || j==n) {
				//printf ("two=%d,one=%d,des=%d\n" , two,one,des) ;
				ret += 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two ;
				ret -= 1ll*des ;
				//cout << "change = " << 1ll*4*two*(two-1)/2 + 1ll*one*(one-1)/2 + 1ll*2*one*two - 1ll*des << endl ;
				last[0] = last[1] = des = two = one = 0 ;
				continue ;
			}
			if (!sumh[j][i]&&!(sumh[j][m]-sumh[j][i-1])) {
				two++ ;
				if (last[0]) des ++ ;
				if (last[1]) des ++ ;
				last[0]=last[1] = 1 ;
			}
			else if (!sumh[j][i]) {
				one++ ;
				if (last[0]) des ++ ;
				last[0]=1 , last[1]=0 ;
			}
			else if (!(sumh[j][m]-sumh[j][i-1])) {
				one++ ;
				if (last[1]) des ++ ;
				last[0]=0 , last[1]=1 ;
			}
			else last[0]=last[1]=0;
		}
	}
	//printf ("ret="LLD"\n",ret) ;
	return ret ;
}

int main () {
	cin >> n >> m ;
	for (int i = 1 ; i <= n ; i ++) scanf ("%s" , s[i]+1) ;
	for (int i = 1 ; i <= n ; i ++) {
		for (int j = 1 ; j <= m ; j ++) {
			sumh[i][j] = sumh[i][j-1] + (s[i][j]=='#'?1:0) ;
			sumv[i][j] = sumv[i-1][j] + (s[i][j]=='#'?1:0) ;
		}
	}

	ans[0] = get_turn0() ;
	ans[1] = get_turn1() ;
	ans[2] = get_turn2() ;
	//for (int i = 0 ; i < 3 ; i ++) printf ("ans[%d]=" LLD "\n" ,i , ans[i]) ;
	printf(LLD,ans[0]+ans[1]+ans[2]) ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define pii pair<pi,ll>
#define pi pair<ll,ll>
#define pb push_back
#define mod 1000000007
#define ll long long int
#define s second
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define fr freopen("input-5.txt","r",stdin)
#define fo freopen("output-5.txt","w",stdout)
char s[2011][2011];
int sh[2011][2011];
int shr[2011][2011];
int svr[2011][2011];
int sv[2011][2011];
int col[2011]={0};
int main(){

	int n,m;
	cin >> n >> m;
	rep(i,n)
		rep(j,m)
			cin >> s[i+1][j+1];
	ll ans1=0;
	ll ans2=0;
	ll ans3=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<m+1;j++){
			if(s[i][j]=='.'){
				sh[i][j]=sh[i][j-1]+1;
				sv[i][j]=sv[i-1][j]+1;
			}
			else{
				sh[i][j]=sh[i][j-1];
				sv[i][j]=sv[i-1][j];
			}
		}
		for(int j=m;j>=1;j--){
			if(s[i][j]=='.'){
				shr[i][j]=shr[i][j+1]+1;
			}
			else{
				shr[i][j]=shr[i][j+1];
			}
		}

		if(i>1 and i<n ){
			if( shr[i][1]==m ) ans1++;
		}

		if( i==n ){
			for(int j=2;j<m;j++ )
				if( sv[i][j]==n ) ans1++;
		}
	}

	for(int i=n;i>0;i--){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				svr[i][j]=svr[i+1][j]+1;
			}
			else{
				svr[i][j]=svr[i+1][j];
			}
		}
	}

	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
			if(sh[i][j]==j and sv[i][j]==i) ans2++;
			if(sh[i][j]==j and svr[i][j]==n-i+1) ans2++;
			if(shr[i][j]==m-j+1 and sv[i][j]==i) ans2++;
			if(shr[i][j]==m-j+1 and svr[i][j]==n-i+1) ans2++;
		}
	}
	for(int i=2;i<n;i++){
		int last=1;
		for(int j=2;j<m;j++){
			col[j]=0;
			if(s[i][j]=='#'){
				last=j;
				continue;
			}
			if(s[i][j]=='.'){
				if(sv[i][j]==i) col[j]++;
				if(svr[i][j]==n-i+1) col[j]++;

			}
			col[j]+=col[j-1];
			if(j>2 and s[i][j]=='.' and s[i][j-1]=='.'){
				if(sv[i][j]==i and svr[i][j-1]==n-i+1) ans3++;
				if(svr[i][j]==n-i+1 and sv[i][j-1]==i) ans3++;
			}
			if( j-2>last){
				if(sv[i][j]==i)
					ans3+=col[j-2];
				if(svr[i][j]==n-i+1)
					ans3+=col[j-2];
			}
			//cout<<col[j]<<" "<<j<<"\n";
		}
	}

	for(int j=2;j<m;j++){
		int last=1;
		for(int i=2;i<n;i++){
			col[i]=0;
			if( s[i][j]=='#' ) {
				last=i;
				continue;
			}
			col[i]=col[i-1];
			if(i-1>1 and s[i][j]=='.' and s[i-1][j]=='.'){
				if(sh[i][j]==j and shr[i-1][j]==m-j+1) ans3++;
				if(shr[i][j]==m-j+1 and sh[i-1][j]==j) ans3++;
			}
			if(shr[i][j]==m-j+1) col[i]++;
			if(sh[i][j]==j) col[i]++;
			if(i-2>last){
				if(shr[i][j]==m-j+1)
					ans3+=col[i-2];
				if(sh[i][j]==j)
					ans3+=col[i-2];
			}
		}
	}
	cout<<ans3+ans2+ans1;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define pii pair<pi,ll>
#define pi pair<ll,ll>
#define pb push_back
#define mod 1000000007
#define ll long long int
#define s second
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define fr freopen("input-5.txt","r",stdin)
#define fo freopen("output-5.txt","w",stdout)
char s[2011][2011];
int sh[2011][2011];
int shr[2011][2011];
int svr[2011][2011];
int sv[2011][2011];
int main(){

	int n,m;
	cin >> n >> m;
	rep(i,n)
		rep(j,m)
			cin >> s[i+1][j+1];
	ll ans1=0;
	ll ans2=0;
	ll ans3=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<m+1;j++){
			if(s[i][j]=='.'){
				sh[i][j]=sh[i][j-1]+1;
				sv[i][j]=sv[i-1][j]+1;
			}
			else{
				sh[i][j]=0;
				sv[i][j]=0;
			}
		}
		for(int j=m;j>=1;j--){
			if(s[i][j]=='.'){
				shr[i][j]=shr[i][j+1]+1;
			}
			else{
				shr[i][j]=0;
			}
		}

		if(i>1 and i<n ){
			if( shr[i][1]==m ) ans1++;
		}

		if( i==n ){
			for(int j=2;j<m;j++ )
				if( sv[i][j]==n ) ans1++;
		}
	}
	for(int i=n;i>0;i--){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				svr[i][j]=svr[i+1][j]+1;
			}
			else{
				svr[i][j]=0;
			}
		}
	}
	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
			if(sh[i][j]==j and sv[i][j]==i) ans2++;
			if(sh[i][j]==j and svr[i][j]==n-i+1) ans2++;
			if(shr[i][j]==m-j+1 and sv[i][j]==i) ans2++;
			if(shr[i][j]==m-j+1 and svr[i][j]==n-i+1) ans2++;
		}
	}
	for(int i=2;i<n;i++){
		ll cur=0;
		for(int j=2;j<m;j++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if(s[i][j-1]!='#'){
					if(sv[i][j-2]==i and j-2>1) cur++;
					if(svr[i][j-2]==n-i+1 and j-2>1) cur++;
				}
				if(sv[i][j]==i and j-2>1){
					ans3+=cur;
				}
				if(sv[i][j]==i and j-1>1 and svr[i][j-1]==n-i+1) ans3++;
				if(svr[i][j]==n-i+1 and j-2>1){
					ans3+=cur;
				}
				if(svr[i][j]==n-i+1 and j-1>1 and sv[i][j-1]==i) ans3++;
			}
		}
	}
	for(int j=2;j<m;j++){
		ll cur=0;
		for(int i=2;i<n;i++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if( s[i-1][j]!='#' ){
					if( sh[i-2][j]==j and i-2>1) cur++;
					if( shr[i-2][j]=m-j+1 and i-2>1) cur++;
				}
				if(sh[i][j]==j and i-2>1) ans3+=cur;
				if(shr[i][j]==m-j+1 and i-2>1) ans3+=cur;
				if(sh[i][j]==j and i-1>1 and shr[i-1][j]==m-j+1) ans3++;
				if(shr[i][j]==m-j+1 and i-1>1 and sh[i-1][j]==j) ans3++;
			}
		}
	}
	cout<<ans3+ans2+ans1;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define pii pair<pi,ll>
#define pi pair<ll,ll>
#define pb push_back
#define mod 1000000007
#define ll long long int
#define s second
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define fr freopen("input-5.txt","r",stdin)
#define fo freopen("output-5.txt","w",stdout)
char s[2011][2011];
int sh[2011][2011];
int shr[2011][2011];
int svr[2011][2011];
int sv[2011][2011];
int main(){

	int n,m;
	cin >> n >> m;
	rep(i,n)
		rep(j,m)
			cin >> s[i+1][j+1];
	ll ans1=0;
	ll ans2=0;
	ll ans3=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<m+1;j++){
			if(s[i][j]=='.'){
				sh[i][j]=sh[i][j-1]+1;
				sv[i][j]=sv[i-1][j]+1;
			}
			else{
				sh[i][j]=0;
				sv[i][j]=0;
			}
		}
		for(int j=m;j>=1;j--){
			if(s[i][j]=='.'){
				shr[i][j]=shr[i][j+1]+1;
			}
			else{
				shr[i][j]=0;
			}
		}

		if(i>1 and i<n ){
			if( shr[i][1]==m ) ans1++;
		}

		if( i==n ){
			for(int j=2;j<m;j++ )
				if( sv[i][j]==n ) ans1++;
		}
	}
	for(int i=n;i>0;i--){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				svr[i][j]=svr[i+1][j]+1;
			}
			else{
				svr[i][j]=0;
			}
		}
	}
	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
			if(sh[i][j]==j and sv[i][j]==i) ans2++;
			if(sh[i][j]==j and svr[i][j]==n-i+1) ans2++;
			if(shr[i][j]==m-j+1 and sv[i][j]==i) ans2++;
			if(shr[i][j]==m-j+1 and svr[i][j]==n-i+1) ans2++;
		}
	}
	for(int i=2;i<n;i++){
		ll cur=0;
		for(int j=2;j<m;j++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if(s[i][j-1]!='#'){
					if(sv[i][j-2]==i and j-2>1) cur++;
					if(svr[i][j-2]==n-i+1 and j-2>1) cur++;
				}
				if(sv[i][j]==i and j-2>1){
					ans3+=cur;
				}
				if(sv[i][j]==i and j-1>1 and svr[i][j-1]==n-i+1) ans3++;
				if(svr[i][j]==n-i+1 and j-2>1){
					ans3+=cur;
				}
				if(svr[i][j]==n-i+1 and j-1>1 and sv[i][j-1]==i) ans3++;
			}
		}
	}
	for(int j=2;j<m;j++){
		ll cur=0;
		for(int i=2;i<n;i++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if( s[i-1][j]!='#' ){
					if( sh[i-2][j]==j and i-2>1) cur++;
					if( shr[i-2][j]=m-j+1 and i-2>1) cur++;
				}
				if(sh[i][j]==j and i-2>1) ans3+=cur;
				if(shr[i][j]==m-j+1 and i-2>1) ans3+=cur;
				if(sh[i][j]==j and i-1>1 and shr[i-1][j]==m-j+1) ans3++;
				if(shr[i][j]==m-j+1 and i-1>1 and sh[i-1][j]==j) ans3++;
			}
		}
	}
	cerr<<ans3<<" ";
	cout<<ans3+ans2+ans1;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define pii pair<pi,ll>
#define pi pair<ll,ll>
#define pb push_back
#define mod 1000000007
#define ll long long int
#define s second
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define fr freopen("input-5.txt","r",stdin)
#define fo freopen("output-5.txt","w",stdout)
char s[2011][2011];
int sh[2011][2011];
int shr[2011][2011];
int svr[2011][2011];
int sv[2011][2011];
int main(){

	int n,m;
	cin >> n >> m;
	rep(i,n)
		rep(j,m)
			cin >> s[i+1][j+1];
	ll ans1=0;
	ll ans2=0;
	ll ans3=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<m+1;j++){
			if(s[i][j]=='.'){
				sh[i][j]=sh[i][j-1]+1;
				sv[i][j]=sv[i-1][j]+1;
			}
			else{
				sh[i][j]=sh[i][j-1];
				sv[i][j]=sv[i-1][j];
			}
		}
		for(int j=m;j>=1;j--){
			if(s[i][j]=='.'){
				shr[i][j]=shr[i][j+1]+1;
			}
			else{
				shr[i][j]=shr[i][j+1];
			}
		}

		if(i>1 and i<n ){
			if( shr[i][1]==m ) ans1++;
		}

		if( i==n ){
			for(int j=2;j<m;j++ )
				if( sv[i][j]==n ) ans1++;
		}
	}

	for(int i=n;i>0;i--){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				svr[i][j]=svr[i+1][j]+1;
			}
			else{
				svr[i][j]=svr[i+1][j];
			}
		}
	}

	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
			if(sh[i][j]==j and sv[i][j]==i) ans2++;
			if(sh[i][j]==j and svr[i][j]==n-i+1) ans2++;
			if(shr[i][j]==m-j+1 and sv[i][j]==i) ans2++;
			if(shr[i][j]==m-j+1 and svr[i][j]==n-i+1) ans2++;
		}
	}
	for(int i=2;i<n;i++){
		ll cur=0;
		for(int j=2;j<m;j++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if(s[i][j-1]!='#'){
					if(sv[i][j-2]==i and j-2>1) cur++;
					if(svr[i][j-2]==n-i+1 and j-2>1) cur++;
				}
				if(sv[i][j]==i and j-2>1){
					ans3+=cur;
				}
				if(sv[i][j]==i and j-1>1 and svr[i][j-1]==n-i+1) ans3++;
				if(svr[i][j]==n-i+1 and j-2>1){
					ans3+=cur;
				}
				if(svr[i][j]==n-i+1 and j-1>1 and sv[i][j-1]==i) ans3++;
			}
		}
	}
	//cerr<<ans3<<" ";
	for(int j=2;j<m;j++){
		ll cur=0;
		for(int i=2;i<n;i++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if( s[i-1][j]!='#' ){
					if( sh[i-2][j]==j and i-2>1) cur++;
					if( shr[i-2][j]=m-j+1 and i-2>1) cur++;
				}
				if(sh[i][j]==j and i-2>1) ans3+=cur;
				if(shr[i][j]==m-j+1 and i-2>1) ans3+=cur;
				//if(sh[i][j]==j and i-1>1 and shr[i-1][j]==m-j+1) ans3++;
				//if(shr[i][j]==m-j+1 and i-1>1 and sh[i-1][j]==j) ans3++;
			}
		}
	}
	cout<<ans3+ans2+ans1;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define pii pair<pi,ll>
#define pi pair<ll,ll>
#define pb push_back
#define mod 1000000007
#define ll long long int
#define s second
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define fr freopen("input-5.txt","r",stdin)
#define fo freopen("output-5.txt","w",stdout)
char s[2011][2011];
int sh[2011][2011];
int shr[2011][2011];
int svr[2011][2011];
int sv[2011][2011];
int main(){

	int n,m;
	cin >> n >> m;
	rep(i,n)
		rep(j,m)
			cin >> s[i+1][j+1];
	int ans1=0;
	int ans2=0;
	int ans3=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<m+1;j++){
			if(s[i][j]=='.'){
				sh[i][j]=sh[i][j-1]+1;
				sv[i][j]=sv[i-1][j]+1;
			}
			else{
				sh[i][j]=0;
				sv[i][j]=0;
			}
		}
		for(int j=m;j>=1;j--){
			if(s[i][j]=='.'){
				shr[i][j]=shr[i][j+1]+1;
			}
			else{
				shr[i][j]=0;
			}
		}

		if(i>1 and i<n ){
			if( shr[i][1]==m ) ans1++;
		}

		if( i==n ){
			for(int j=2;j<m;j++ )
				if( sv[i][j]==n ) ans1++;
		}
	}
	for(int i=n;i>0;i--){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				svr[i][j]=svr[i+1][j]+1;
			}
			else{
				svr[i][j]=0;
			}
		}
	}
	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
			if(sh[i][j]==j and sv[i][j]==i) ans2++;
			if(sh[i][j]==j and svr[i][j]==n-i+1) ans2++;
			if(shr[i][j]==m-j+1 and sv[i][j]==i) ans2++;
			if(shr[i][j]==m-j+1 and svr[i][j]==n-i+1) ans2++;
		}
	}
	for(int i=2;i<n;i++){
		int cur=0;
		for(int j=2;j<m;j++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if(s[i][j-1]!='#'){
					if(sv[i][j-2]==i and j-2>1) cur++;
					if(svr[i][j-2]==n-i+1 and j-2>1) cur++;
				}
				if(sv[i][j]==i and j-2>1){
					ans3+=cur;
				}
				if(sv[i][j]==i and j-1>1 and svr[i][j-1]==n-i+1) ans3++;
				if(svr[i][j]==n-i+1 and j-2>1){
					ans3+=cur;
				}
				if(svr[i][j]==n-i+1 and j-1>1 and sv[i][j-1]==i) ans3++;
			}
		}
	}
	for(int j=2;j<m;j++){
		int cur=0;
		for(int i=2;i<n;i++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if( s[i-1][j]!='#' ){
					if( sh[i-2][j]==j and i-2>1) cur++;
					if( shr[i-2][j]=m-j+1 and i-2>1) cur++;
				}
				if(sh[i][j]==j and i-2>1) ans3+=cur;
				if(shr[i][j]==m-j+1 and i-2>1) ans3+=cur;
				if(sh[i][j]==j and i-1>1 and shr[i-1][j]==m-j+1) ans3++;
				if(shr[i][j]==m-j+1 and i-1>1 and sh[i-1][j]==j) ans3++;
			}
		}
	}
	cout<<ans3+ans2+ans1;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define pii pair<pi,ll>
#define pi pair<ll,ll>
#define pb push_back
#define mod 1000000007
#define ll long long int
#define s second
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define fr freopen("input-5.txt","r",stdin)
#define fo freopen("output-5.txt","w",stdout)
char s[2011][2011];
int sh[2011][2011];
int shr[2011][2011];
int svr[2011][2011];
int sv[2011][2011];
int main(){

	int n,m;
	cin >> n >> m;
	rep(i,n)
		rep(j,m)
			cin >> s[i+1][j+1];
	ll ans1=0;
	ll ans2=0;
	ll ans3=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<m+1;j++){
			if(s[i][j]=='.'){
				sh[i][j]=sh[i][j-1]+1;
				sv[i][j]=sv[i-1][j]+1;
			}
			else{
				sh[i][j]=sh[i][j-1];
				sv[i][j]=sv[i-1][j];
			}
		}
		for(int j=m;j>=1;j--){
			if(s[i][j]=='.'){
				shr[i][j]=shr[i][j+1]+1;
			}
			else{
				shr[i][j]=shr[i][j+1];
			}
		}

		if(i>1 and i<n ){
			if( shr[i][1]==m ) ans1++;
		}

		if( i==n ){
			for(int j=2;j<m;j++ )
				if( sv[i][j]==n ) ans1++;
		}
	}

	for(int i=n;i>0;i--){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				svr[i][j]=svr[i+1][j]+1;
			}
			else{
				svr[i][j]=svr[i+1][j];
			}
		}
	}

	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
			if(sh[i][j]==j and sv[i][j]==i) ans2++;
			if(sh[i][j]==j and svr[i][j]==n-i+1) ans2++;
			if(shr[i][j]==m-j+1 and sv[i][j]==i) ans2++;
			if(shr[i][j]==m-j+1 and svr[i][j]==n-i+1) ans2++;
		}
	}
	for(int i=2;i<n;i++){
		ll cur=0;
		for(int j=2;j<m;j++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if(s[i][j-1]!='#'){
					if(sv[i][j-2]==i and j-2>1) cur++;
					if(svr[i][j-2]==n-i+1 and j-2>1) cur++;
				}
				if(sv[i][j]==i and j-2>1){
					ans3+=cur;
				}
				if(sv[i][j]==i and j-1>1 and svr[i][j-1]==n-i+1) ans3++;
				if(svr[i][j]==n-i+1 and j-2>1){
					ans3+=cur;
				}
				if(svr[i][j]==n-i+1 and j-1>1 and sv[i][j-1]==i) ans3++;
			}
		}
	}
	//cerr<<ans3<<" ";
	for(int j=2;j<m;j++){
		ll cur=0;
		for(int i=2;i<n;i++){
			if(s[i][j]=='#'){
				cur=0;
			}
			else{
				if( s[i-1][j]!='#' ){
					if( sh[i-2][j]==j and i-2>1) cur++;
					if( shr[i-2][j]=m-j+1 and i-2>1) cur++;
				}
				if(sh[i][j]==j and i-2>1) ans3+=cur;
				if(shr[i][j]==m-j+1 and i-2>1) ans3+=cur;
				if(sh[i][j]==j and i-1>1 and shr[i-1][j]==m-j+1) ans3++;
				if(shr[i][j]==m-j+1 and i-1>1 and sh[i-1][j]==j) ans3++;
			}
		}
	}
	cout<<ans3+ans2+ans1;
}


#include <bits/stdc++.h>

#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back

#define y0 yy0
#define y1 yy1
#define next _next
#define prev _prev
#define link _link
#define hash _hash

#define sz(s) int((s).size())
#define len(s) int((s).size())
#define all(s) (s).begin(), (s).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 1e6;
const ll lINF = 1e18;
const double EPS = 1e-12;

#ifdef DEBUG
#define LLD "%lld"
#else
#define LLD "%I64d"
#endif

using namespace std;

const int N = 2200;

int n, m;
char s[N][N];
bool l[N][N], r[N][N], u[N][N], d[N][N];

int main()
{
#ifdef DEBUG
    freopen ("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf(" %s", s[i]);
    }
    for (int i = 0; i < n; i++) {
        l[i][0] = (s[i][0] == '.');
        for (int j = 1; j < m; j++) {
            l[i][j] = l[i][j - 1];
            if (s[i][j] == '#') {
                l[i][j] = false;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        r[i][m - 1] = (s[i][m - 1] == '.');
        for (int j = m - 2; j >= 0; j--) {
            r[i][j] = r[i][j + 1];
            if (s[i][j] == '#') {
                r[i][j] = false;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        u[0][i] = (s[0][i] == '.');
        for (int j = 1; j < n; j++) {
            u[j][i] = u[j - 1][i];
            if (s[j][i] == '#') {
                u[j][i] = false;
            }
        }
    }
    for (int i = 0; i < m; i++) {
        d[n - 1][i] = (s[n - 1][i] == '.');
        for (int j = n - 2; j >= 0; j--) {
            d[j][i] = d[j + 1][i];
            if (s[j][i] == '#') {
                d[j][i] = false;
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (r[i][0]) {
            ans++;
        }
    }
    for (int j = 1; j < m - 1; j++) {
        if (d[0][j]) {
            ans++;
        }
    }
    for (int i = 1; i < n - 1; i++) {
        for (int j = 1; j < m - 1; j++) {
            int cnt = 0;
            if (l[i][j] && u[i][j]) {
                ans++;
            }
            if (l[i][j] && d[i][j]) {
                ans++;
            }
            if (r[i][j] && u[i][j]) {
                ans++;
            }
            if (r[i][j] && d[i][j]) {
                ans++;
            }
        }
    }
    for (int i = 1; i < n - 1; i++) {
        int cnt = 0;
        for (int j = 1; j < m; j++) {
            if (j < m - 2) {
                if (u[i][j] && u[i][j + 1]) {
                    ans--;
                }
                if (d[i][j] && d[i][j + 1]) {
                    ans--;
                }
            }
            if (s[i][j] == '#' || j == m - 1) {
                cnt = 0;
            } else {
                if (d[i][j]) {
                    ans += cnt;
                }
                if (u[i][j]) {
                    ans += cnt;
                }
                if (u[i][j]) {
                    cnt++;
                }
                if (d[i][j]) {
                    cnt++;
                }
            }
        }
    }
    for (int j = 1; j < m - 1; j++) {
        int cnt = 0;
        for (int i = 1; i < n; i++) {
            if (i < n - 2) {
                if (l[i][j] && l[i + 1][j]) {
                    ans--;
                }
                if (r[i][j] && r[i + 1][j]) {
                    ans--;
                }
            }
            if (s[i][j] == '#' || i == n - 1) {
                cnt = 0;
            } else {
                if (r[i][j]) {
                    ans += cnt;
                }
                if (l[i][j]) {
                    ans += cnt;
                }
                if (l[i][j]) {
                    cnt++;
                }
                if (r[i][j]) {
                    cnt++;
                }
            }
        }
    }

    printf(LLD"\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define int long long
using namespace std;

struct fenwicktree
{
    int n;
    vector <int> bit;

    fenwicktree (int _n)
    {
        n = _n;
        bit.assign(n + 5, 0);
    }

    void update(int pos, int val)
    {
        for (; pos <= n; pos += pos & -pos) bit[pos] += val;
    }

    int getsum(int pos)
    {
        int res = 0;
        for (; pos > 0; pos -= pos & -pos) res += bit[pos];
        return res;
    }

    int getsum(int l, int r)
    {
        return getsum(r) - getsum(l - 1);
    }
};

int l[2005];
int r[2005];
int u[2005];
int d[2005];
int a[2005][2005];
int b[2005][2005];
int mx[2005][2005];
int n,m;

void print(int a[2005][2005], int n, int m)
{
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        cerr << a[i][j] << " ";
        if (j == m) cerr << endl;
    }
}

int solve(int a[2005][2005], int n, int m)
{
    for (int i = n; i >= 1; i--)
    for (int j = 1; j <= m; j++)
    {
        if (a[i][j]) mx[i][j] = 0;
        else mx[i][j] = mx[i + 1][j] + 1;
    }
    for (int i = 2; i < n; i++)
    {
        l[i] = 0;
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j]) break;
            l[i]++;
        }
        r[i] = m + 1;
        for (int j = m; j >= 1; j--)
        {
            if (a[i][j]) break;
            r[i]--;
        }
    }
    for (int j = 2; j < m; j++)
    {
        u[j] = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i][j]) break;
            u[j]++;
        }
        d[j] = n + 1;
        for (int i = n; i >= 1; i--)
        {
            if (a[i][j]) break;
            d[j]--;
        }
    }
    //================================
    int res = 0;
    for (int i = 2; i < n; i++) if (!a[i][1])
    {
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j < m; j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end());
        reverse(seg.begin(), seg.end());
        for (int j = i + 2; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] >= 2) res += 2 * bit.getsum(2, l[j]);
        }
    }
    //=================================
    for (int i = 2; i < n; i++)
    {
        res += (l[i] == m);
        /** from the left to the right */
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j <= min(m - 1, l[i]); j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (r[j] < n) res += bit.getsum(r[j], n - 1);
        }
        /** from the right to the left */
        seg.clear();
        bit = fenwicktree(m);
        for (int j = m - 1; j >= max(2LL, r[i]); j--)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] > 1) res += bit.getsum(2, l[j]);
        }
    }
    //=======================================================
    for (int i = 2; i < n; i++)
    for (int j = 2; j <= min(m - 1, l[i]); j++)
    {
        res += (i <= u[j]);
        res += (i >= d[j]);
    }
    return res;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        char c; cin >> c;
        a[i][j] = (c == '#');
    }
    int ans = 0;
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[i][j];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[j][m - i + 1];
    }
    ans += solve(b, m, n);
    //print(b, m, n);
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[n - i + 1][m - j + 1];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[n - j + 1][i];
    }
    //print(b, m, n);
    ans += solve(b, m, n);
    //=========================
    cout << ans / 2;
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define int long long
using namespace std;

struct fenwicktree
{
    int n;
    vector <int> bit;

    fenwicktree (int _n)
    {
        n = _n;
        bit.assign(n + 5, 0);
    }

    void update(int pos, int val)
    {
        for (; pos <= n; pos += pos & -pos) bit[pos] += val;
    }

    int getsum(int pos)
    {
        int res = 0;
        for (; pos > 0; pos -= pos & -pos) res += bit[pos];
        return res;
    }

    int getsum(int l, int r)
    {
        return getsum(r) - getsum(l - 1);
    }
};

int l[2005];
int r[2005];
int u[2005];
int d[2005];
int a[2005][2005];
int b[2005][2005];
int mx[2005][2005];
int n,m;

void print(int a[2005][2005], int n, int m)
{
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        cerr << a[i][j] << " ";
        if (j == m) cerr << endl;
    }
}

int solve(int a[2005][2005], int n, int m)
{
    for (int i = n; i >= 1; i--)
    for (int j = 1; j <= m; j++)
    {
        if (a[i][j]) mx[i][j] = 0;
        else mx[i][j] = mx[i + 1][j] + 1;
    }
    for (int i = 2; i < n; i++)
    {
        l[i] = 0;
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j]) break;
            l[i]++;
        }
        r[i] = m + 1;
        for (int j = m; j >= 1; j--)
        {
            if (a[i][j]) break;
            r[i]--;
        }
    }
    for (int j = 2; j < m; j++)
    {
        u[j] = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i][j]) break;
            u[j]++;
        }
        d[j] = n + 1;
        for (int i = n; i >= 1; i--)
        {
            if (a[i][j]) break;
            d[j]--;
        }
    }
    //================================
    int res = 0;
    for (int i = 2; i < n; i++) if (!a[i][1])
    {
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j < m; j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end());
        reverse(seg.begin(), seg.end());
        for (int j = i + 2; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] >= 2) res += 2 * bit.getsum(2, l[j]);
        }
    }
    //=================================
    for (int i = 2; i < n; i++)
    {
        res += (l[i] == m);
        /** from the left to the right */
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j <= min(m - 1, l[i]); j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (r[j] < m) res += bit.getsum(r[j], m - 1);
        }
        /** from the right to the left */
        seg.clear();
        bit = fenwicktree(m);
        for (int j = m - 1; j >= max(2LL, r[i]); j--)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] > 1) res += bit.getsum(2, l[j]);
        }
    }
    //=======================================================
    for (int i = 2; i < n; i++)
    for (int j = 2; j <= min(m - 1, l[i]); j++)
    {
        res += (i <= u[j]);
        res += (i >= d[j]);
    }
    return res;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        char c; cin >> c;
        a[i][j] = (c == '#');
    }
    int ans = 0;
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[i][j];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[j][m - i + 1];
    }
    ans += solve(b, m, n);
    //print(b, m, n);
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[n - i + 1][m - j + 1];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[n - j + 1][i];
    }
    //print(b, m, n);
    ans += solve(b, m, n);
    //=========================
    cout << ans / 2;
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define int long long
using namespace std;

struct fenwicktree
{
    int n;
    vector <int> bit;

    fenwicktree (int _n)
    {
        n = _n;
        bit.assign(n + 5, 0);
    }

    void update(int pos, int val)
    {
        for (; pos <= n; pos += pos & -pos) bit[pos] += val;
    }

    int getsum(int pos)
    {
        int res = 0;
        for (; pos > 0; pos -= pos & -pos) res += bit[pos];
        return res;
    }

    int getsum(int l, int r)
    {
        return getsum(r) - getsum(l - 1);
    }
};

int l[2005];
int r[2005];
int u[2005];
int d[2005];
int a[2005][2005];
int b[2005][2005];
int mx[2005][2005];
int n,m;

void print(int a[2005][2005], int n, int m)
{
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        cerr << a[i][j] << " ";
        if (j == m) cerr << endl;
    }
}

int solve(int a[2005][2005], int n, int m)
{
    for (int i = n; i >= 1; i--)
    for (int j = 1; j <= m; j++)
    {
        if (a[i][j]) mx[i][j] = 0;
        else mx[i][j] = mx[i + 1][j] + 1;
    }
    for (int i = 2; i < n; i++)
    {
        l[i] = 0;
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j]) break;
            l[i]++;
        }
        r[i] = m + 1;
        for (int j = m; j >= 1; j--)
        {
            if (a[i][j]) break;
            r[i]--;
        }
    }
    for (int j = 2; j < m; j++)
    {
        u[j] = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i][j]) break;
            u[j]++;
        }
        d[j] = n + 1;
        for (int i = n; i >= 1; i--)
        {
            if (a[i][j]) break;
            d[j]--;
        }
    }
    //================================
    int res = 0;
    for (int i = 2; i < n; i++) if (!a[i][1])
    {
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j < m; j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end());
        reverse(seg.begin(), seg.end());
        for (int j = i + 2; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] >= 2) res += 2 * bit.getsum(2, l[j]);
        }
    }
    //=================================
    for (int i = 2; i < n; i++)
    {
        res += (l[i] == m);
        /** from the left to the right */
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j <= min(m - 1, l[i]); j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (r[j] < n) res += bit.getsum(r[j], n - 1);
        }
        /** from the right to the left */
        seg.clear();
        bit = fenwicktree(m);
        for (int j = m - 1; j >= max(2, r[i]); j--)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] > 1) res += bit.getsum(2, l[j]);
        }
    }
    //=======================================================
    for (int i = 2; i < n; i++)
    for (int j = 2; j <= min(m - 1, l[i]); j++)
    {
        res += (i <= u[j]);
        res += (i >= d[j]);
    }
    return res;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        char c; cin >> c;
        a[i][j] = (c == '#');
    }
    int ans = 0;
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[i][j];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[j][m - i + 1];
    }
    ans += solve(b, m, n);
    //print(b, m, n);
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[n - i + 1][m - j + 1];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[n - j + 1][i];
    }
    //print(b, m, n);
    ans += solve(b, m, n);
    //=========================
    cout << ans / 2;
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

struct fenwicktree
{
    int n;
    vector <int> bit;

    fenwicktree (int _n)
    {
        n = _n;
        bit.assign(n + 5, 0);
    }

    void update(int pos, int val)
    {
        for (; pos <= n; pos += pos & -pos) bit[pos] += val;
    }

    int getsum(int pos)
    {
        int res = 0;
        for (; pos > 0; pos -= pos & -pos) res += bit[pos];
        return res;
    }

    int getsum(int l, int r)
    {
        return getsum(r) - getsum(l - 1);
    }
};

int l[2005];
int r[2005];
int u[2005];
int d[2005];
int a[2005][2005];
int b[2005][2005];
int mx[2005][2005];
int n,m;

void print(int a[2005][2005], int n, int m)
{
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        cerr << a[i][j] << " ";
        if (j == m) cerr << endl;
    }
}

int solve(int a[2005][2005], int n, int m)
{
    for (int i = n; i >= 1; i--)
    for (int j = 1; j <= m; j++)
    {
        if (a[i][j]) mx[i][j] = 0;
        else mx[i][j] = mx[i + 1][j] + 1;
    }
    for (int i = 2; i < n; i++)
    {
        l[i] = 0;
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j]) break;
            l[i]++;
        }
        r[i] = m + 1;
        for (int j = m; j >= 1; j--)
        {
            if (a[i][j]) break;
            r[i]--;
        }
    }
    for (int j = 2; j < m; j++)
    {
        u[j] = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i][j]) break;
            u[j]++;
        }
        d[j] = n + 1;
        for (int i = n; i >= 1; i--)
        {
            if (a[i][j]) break;
            d[j]--;
        }
    }
    //================================
    int res = 0;
    for (int i = 2; i < n; i++) if (!a[i][1])
    {
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j < m; j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end());
        reverse(seg.begin(), seg.end());
        for (int j = i + 2; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] >= 2) res += 2 * bit.getsum(2, l[j]);
        }
    }
    //=================================
    for (int i = 2; i < n; i++)
    {
        res += (l[i] == m);
        /** from the left to the right */
        vector <pair <int, int>> seg;
        fenwicktree bit(m);
        for (int j = 2; j <= min(m - 1, l[i]); j++)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (r[j] < n) res += bit.getsum(r[j], n - 1);
        }
        /** from the right to the left */
        seg.clear();
        bit = fenwicktree(m);
        for (int j = m - 1; j >= max(2, r[i]); j--)
        {
            if (a[i][j]) break;
            seg.push_back(mp(mx[i][j], j));
            bit.update(j, 1);
        }
        sort(seg.begin(), seg.end()); reverse(seg.begin(), seg.end());
        for (int j = i + 1; j < n; j++)
        {
            while (seg.size() && j - i + 1 > seg.back().fi)
            {
                bit.update(seg.back().se, -1);
                seg.pop_back();
            }
            if (l[j] > 1) res += bit.getsum(2, l[j]);
        }
    }
    //=======================================================
    for (int i = 2; i < n; i++)
    for (int j = 2; j <= min(m - 1, l[i]); j++)
    {
        res += (i <= u[j]);
        res += (i >= d[j]);
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        char c; cin >> c;
        a[i][j] = (c == '#');
    }
    int ans = 0;
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[i][j];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[j][m - i + 1];
    }
    ans += solve(b, m, n);
    //print(b, m, n);
    //==========================
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    {
        b[i][j] = a[n - i + 1][m - j + 1];
    }
    ans += solve(b, n, m);
    //print(b, n, m);
    //==========================
    for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
    {
        b[i][j] = a[n - j + 1][i];
    }
    //print(b, m, n);
    ans += solve(b, m, n);
    //=========================
    cout << ans / 2;
    return 0;
}


#include <bits/stdc++.h>
#define _ ios::sync_with_stdio(0);cin.tie(0);
#define cerr if(0)cerr
#define int long long

using namespace std;

constexpr int N = 2222;

int a[N][N], num[N][N], r[N][N], l[N][N], u[N][N], d[N][N], ans, n, m;

int doaz(int x){
    return x * (x-1) / 2;
}
bool ok(int x, int y){
    return (x > 1 && y > 1 && y < m && x < n);
}
main(){_
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++){
            char c; cin >> c;
            a[i][j] = (c=='#');
        }
    for(int i = 1; i <= n; i++){
        int f = 0;
        for(int j = 1; j <= m; j++){
            f |= a[i][j];
            if (!a[i][j]) {if(ok(i,j)) r[i][j] ++;}
            else break;
        }
        for(int j = m; j > 0; --j)
            if (!a[i][j]) {if(ok(i,j)) l[i][j] ++;}
            else break;
        ans += (i > 1 && i < n && !f);
    }
    for(int j = 1; j <= m; j++){
        int f = 0;
        for(int i = 1; i <= n; i++){
            f |= a[i][j];
            if (!a[i][j]) {if(ok(i,j)) u[i][j] ++;}
            else break;
        }
        for(int i = n; i > 0; i--)
            if (!a[i][j]) {if(ok(i,j)) d[i][j] ++;}
            else break;
        ans += (j > 1 && j < m && !f);
    }
    cerr << ans << '\n';
    for(int i = 2; i < n; i++){
        int uu = 0, dd = 0, pos = 2;
        for(int j = 2; j < m; j++){
            ans += (u[i][j] && l[i][j]) + (u[i][j] && r[i][j]) + (d[i][j] && l[i][j]) + (d[i][j] && r[i][j]);;
            if (a[i][j]){
                cerr << i <<' '<< j <<' ' << uu << ' ' << dd << '\n';
                ans += (uu * dd) + doaz(uu) + doaz(dd);
                for(int x = pos; x < j; x++){
                    if(d[i][x]) ans -= (u[i][x] + d[i][x-1]);
                    if(u[i][x]) ans -= (u[i][x-1]);
                }
                uu = dd = 0; pos = j+1;
            }
            else{
                uu += u[i][j];
                dd += d[i][j];
            }
        }
        ans += (uu * dd) + doaz(uu) + doaz(dd);
        for(int x = pos; x < m; x++){
            cerr << i <<' '<<' ' << uu << ' ' << dd << '\n';
            if(d[i][x]) ans -= (u[i][x] + d[i][x-1]);
            if(u[i][x]) ans -= (u[i][x-1]);
        }
    }
    cerr << ans << "  **************  "<< '\n';
    for(int j = 2; j < m; j++){
        int uu = 0, dd = 0, pos = 2;
        for(int i = 2; i < n; i++){
            //cerr << i <<' '<< j <<' ' << uu << ' ' << dd << '\n';
            //ans += (d[i][j] && l[i][j]) + (d[i][j] && r[i][j]);
            if (a[i][j]){
                cerr << i <<' '<< j <<' ' << uu << ' ' << dd << '\n';
                ans += (uu * dd) + doaz(uu) + doaz(dd);
                for(int x = pos; x < i; x++){
                    if(l[x][j]) ans -= (r[x][j] + l[x-1][j]);
                    if(r[x][j]) ans -= (r[x-1][j]);
                }
                uu = dd = 0; pos = i+1;
            }
            else{
                uu += l[i][j];
                dd += r[i][j];
            }
        }
        ans += (uu * dd) + doaz(uu) + doaz(dd);
        for(int x = pos; x < n; x++){
            cerr << j <<' '<<' ' << uu << ' ' << dd << '\n';
            if(l[x][j]) ans -= (r[x][j] + l[x-1][j]);
            if(r[x][j]) ans -= (r[x-1][j]);
        }
    }
    cout << ans << endl;
}


//I can't believe in you..

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

const ll MAXN = 2e3 + 10;

char c[MAXN][MAXN], sc[MAXN][MAXN];
ll dn[MAXN][MAXN], ri[MAXN][MAXN], le[MAXN][MAXN], up[MAXN][MAXN], p[MAXN][MAXN], d[MAXN][MAXN];
ll n, m, aa, bb, cc, dd;

void rotate(){
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			sc[m - j - 1][i] = c[i][j];
	swap(n, m);
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			c[i][j] = sc[i][j];
}

void get_partial(){
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			p[i + 1][j + 1] = p[i][j + 1] + d[i][j];
}

void cal(){
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			if (c[i][j] == '#')	up[i][j] = le[i][j] = 0;
			else{
				if (i == 0)	up[i][j] = 1;
				else	up[i][j] = 1 + up[i - 1][j];
				if (j == 0)	le[i][j] = 1;
				else	le[i][j] = 1 + le[i][j - 1];
			}
	for (ll i = n - 1; i >= 0; i--)
		for (ll j = m - 1; j >= 0; j--)
			if (c[i][j] == '#')	dn[i][j] = ri[i][j] = 0;
			else{
				if (i == n - 1)	dn[i][j] = 1;
				else	dn[i][j] = 1 + dn[i + 1][j];
				if (j == m - 1)	ri[i][j] = 1;
				else	ri[i][j] = 1 + ri[i][j + 1];
			}

	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)	d[i][j] = 0;

	for (ll i = 1; i < n - 1; i++)	if (ri[i][0] == m)	aa++;
	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++){
			if (le[i][j] == j + 1 && up[i][j] == i + 1)	bb++;
			if (le[i][j] == j + 1 && dn[i][j] == n - i)	bb++;
		}

	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)
			d[i][j] = bool(ri[i][j] == m - j);
	get_partial();
	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)
			if (le[i][j] == j + 1){
				cc += p[i][j + 1] - p[i + 1 - up[i][j]][j + 1];
				cc += p[i + 1 +dn[i][j]][j + 1] - p[i + 1][j + 1];
			}

	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)	d[i][j] = bool(le[i][j] == j + 1);
	get_partial();
	for (ll i = 2; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)
			if (le[i][j] == j + 1 && up[i][j] > 2)
				dd += p[i - 1][j + 1] - p[i + 1 - up[i][j]][j + 1];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (ll i = 0; i < n; i++){
		string temp;	cin >> temp;
		for (ll j = 0; j < m; j++)
			c[i][j] = temp[j];
	}
	for (ll i = 0; i < 4; i++)	cal(), rotate();
	cout << aa/2 + bb/2 + cc/2 + dd << "\n";
	return	0;
}


//I can't believe in you..

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

const ll MAXN = 2e3 + 10;

char c[MAXN][MAXN], sc[MAXN][MAXN];
ll dn[MAXN][MAXN], ri[MAXN][MAXN], le[MAXN][MAXN], up[MAXN][MAXN], p[MAXN][MAXN], d[MAXN][MAXN];
ll n, m, aa, bb, cc, dd;

void rotate(){
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			sc[m - j - 1][i] = c[i][j];
	swap(n, m);
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			c[i][j] = sc[i][j];
}

void get_partial(){
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			p[i + 1][j + 1] = p[i][j + 1] + d[i][j];
}

void cal(){
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			if (c[i][j] == '#')	up[i][j] = le[i][j] = 0;
			else{
				if (i == 0)	up[i][j] = 1;
				else	up[i][j] = 1 + up[i - 1][j];
				if (j == 0)	le[i][j] = 1;
				else	le[i][j] = 1 + le[i][j - 1];
			}
	for (ll i = n - 1; i >= 0; i--)
		for (ll j = m - 1; j >= 0; j--)
			if (c[i][j] == '#')	dn[i][j] = ri[i][j] = 0;
			else{
				if (i == n - 1)	dn[i][j] = 1;
				else	dn[i][j] = 1 + dn[i + 1][j];
				if (j == m - 1)	ri[i][j] = 1;
				else	ri[i][j] = 1 + ri[i][j + 1];
			}

	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)	d[i][j] = 0;

	for (ll i = 1; i < n - 1; i++)	if (ri[i][0] == m)	aa++;
	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++){
			if (le[i][j] == j + 1 && up[i][j] == i + 1)	bb++;
			if (le[i][j] == j + 1 && dn[i][j] == n - i)	bb++;
		}

	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)
			d[i][j] = bool(ri[i][j] == m - j);
	get_partial();
	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)
			if (le[i][j] == j + 1){
				cc += p[i][j + 1] - p[i + 1 - up[i][j]][j + 1];
				cc += p[i + dn[i][j]][j + 1] - p[i + 1][j + 1];
			}

	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)	d[i][j] = bool(le[i][j] == j + 1);
	get_partial();
	for (ll i = 1; i < n - 1; i++)
		for (ll j = 1; j < m - 1; j++)
			if (le[i][j] == j + 1 && up[i][j] > 2)
				dd += p[i - 1][j + 1] - p[i + 1 - up[i][j]][j + 1];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (ll i = 0; i < n; i++){
		string temp;	cin >> temp;
		for (ll j = 0; j < m; j++)
			c[i][j] = temp[j];
	}
	for (ll i = 0; i < 4; i++)	cal(), rotate();
	cout << aa/2 + bb/2 + cc/2 + dd << "\n";
	return	0;
}


//I can't believe in you..

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

const int MAXN = 2e3 + 10;

char c[MAXN][MAXN], sc[MAXN][MAXN];
int dn[MAXN][MAXN], ri[MAXN][MAXN], le[MAXN][MAXN], up[MAXN][MAXN], p[MAXN][MAXN], d[MAXN][MAXN];
int n, m, aa, bb, cc, dd;

void rotate(){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			sc[m - j - 1][i] = c[i][j];
	swap(n, m);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			c[i][j] = sc[i][j];
}

void get_partial(){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			p[i + 1][j + 1] = p[i][j + 1] + d[i][j];
}

void cal(){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (c[i][j] == '#')	up[i][j] = le[i][j] = 0;
			else{
				if (i == 0)	up[i][j] = 1;
				else	up[i][j] = 1 + up[i - 1][j];
				if (j == 0)	le[i][j] = 1;
				else	le[i][j] = 1 + le[i][j - 1];
			}
	for (int i = n - 1; i >= 0; i--)
		for (int j = m - 1; j >= 0; j--)
			if (c[i][j] == '#')	dn[i][j] = ri[i][j] = 0;
			else{
				if (i == n - 1)	dn[i][j] = 1;
				else	dn[i][j] = 1 + dn[i + 1][j];
				if (j == m - 1)	ri[i][j] = 1;
				else	ri[i][j] = 1 + ri[i][j + 1];
			}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)	d[i][j] = 0;

	for (int i = 1; i < n - 1; i++)	if (ri[i][0] == m)	aa++;
	for (int i = 1; i < n - 1; i++)
		for (int j = 1; j < m - 1; j++){
			if (le[i][j] == j + 1 && up[i][j] == i + 1)	bb++;
			if (le[i][j] == j + 1 && dn[i][j] == n - i)	bb++;
		}

	for (int i = 1; i < n - 1; i++)
		for (int j = 1; j < m - 1; j++)
			d[i][j] = bool(ri[i][j] == m - j);
	get_partial();
	for (int i = 1; i < n - 1; i++)
		for (int j = 1; j < m - 1; j++)
			if (le[i][j] == j + 1){
				cc += p[i][j + 1] - p[i + 1 - up[i][j]][j + 1];
				cc += p[i + 1 +dn[i][j]][j + 1] - p[i + 1][j + 1];
			}

	for (int i = 1; i < n - 1; i++)
		for (int j = 1; j < m - 1; j++)	d[i][j] = bool(le[i][j] == j + 1);
	get_partial();
	for (int i = 2; i < n - 1; i++)
		for (int j = 1; j < m - 1; j++)
			if (le[i][j] == j + 1 && up[i][j] > 2)
				dd += p[i - 1][j + 1] - p[i + 1 - up[i][j]][j + 1];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		string temp;	cin >> temp;
		for (int j = 0; j < m; j++)
			c[i][j] = temp[j];
	}
	for (int i = 0; i < 4; i++)	cal(), rotate();
	cout << aa/2 + bb/2 + cc/2 + dd << "\n";
	return	0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
	ll s=0; bool f=0; char ch=' ';
	while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
	while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
	return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
	if(x<0) {putchar('-'); x=-x;}
	if(x<10) {putchar(x+'0'); return;}
	write(x/10); putchar((x%10)+'0');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=2005;
int n,m;
ll jyl=0;
bool a[N][N],b[N][N],up[N][N],down[N][N],lef[N][N],rig[N][N];
inline void solve(bool Map[][N],int n,int m,bool flg)
{
	int i,j;
	for(j=1;j<=m;j++)
	{
		up[1][j]=Map[1][j]; for(i=2;i<=n;i++) up[i][j]=up[i-1][j]&Map[i][j];
		down[n][j]=Map[n][j]; for(i=n-1;i>=1;i--) down[i][j]=down[i+1][j]&Map[i][j];
	}
	for(i=1;i<=n;i++)
	{
		lef[i][1]=Map[i][1]; for(j=2;j<=m;j++) lef[i][j]=lef[i][j-1]&Map[i][j];
		rig[i][m]=Map[i][m]; for(j=m-1;j>=1;j--) rig[i][j]=rig[i][j+1]&Map[i][j];
	}
	for(i=2;i<n;i++)
	{
		int tmpu=0,tmpd=0,las=1;
		for(j=2;j<m;j++)
		{
			if(!Map[i][j]) {tmpu=tmpd=0; las=j; continue;}
			jyl+=1ll*up[i][j]*tmpd;
			jyl+=1ll*down[i][j]*tmpu;
			if(j!=(las+1)) jyl+=1ll*up[i][j]*(tmpu-up[i][j-1]);
			if(j!=(las+1)) jyl+=1ll*down[i][j]*(tmpd-down[i][j-1]);
			tmpu+=up[i][j]; tmpd+=down[i][j];
		}
	}
	for(j=2;j<m;j++) if(up[1][j]&&down[1][j]) jyl++;
	if(flg)
	{
		for(i=2;i<n;i++) for(j=2;j<m;j++)
		{
			if(lef[i][j]&&down[i][j]) jyl++;
			if(rig[i][j]&&down[i][j]) jyl++;
			if(lef[i][j]&&up[i][j]) jyl++;
			if(rig[i][j]&&up[i][j]) jyl++;
		}
	}
}
int main()
{
	int i,j; string s;
	R(n); R(m);
	for(i=1;i<=n;i++)
	{
		cin>>s; for(j=0;j<s.size();j++) a[i][j+1]=(s[j]=='.')?1:0;
	}
	solve(a,n,m,1);
	for(i=1;i<=n;i++) for(j=1;j<=m;j++) b[j][i]=a[i][j];
	solve(b,m,n,0);
	Wl(jyl);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define PII pair<int,int>
#define PPP pair<PII,PII>
#define PLL pair<long long, long long>
#define sz(x)int((x).size())
#define rep(i,b,e)for(int i=(b);i<(e);i++)
const long long inf = 3e12 + 10;

long long n;
const long long mod = 998244353;
long long dp[100001][201][3];
long long tab[100001];
int z = 200;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> tab[i];
    }
    if( n == 2 ){
        if( tab[1] == -1 && tab[2] == -1 ){
            cout << 200 << endl;
            return 0;
        }
        if( tab[1] == -1 || tab[2] == -1 ){
            cout << 1 << endl;
            return 0;
        }
        if( tab[1] == tab[2] ){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }

    for( int i = 1; i <= z; i++ ){
        if( tab[2] != -1 && tab[2] != i){
            continue;
        }
        for( int k = 1; k < i ; k++ ){
            if( tab[1] == -1 || tab[1] == k ){
                dp[2][i][0]++;
            }
        }
        if( tab[1] == -1 || tab[1] == i ){
            dp[2][i][2]++;
        }
    }

    for( int i = 3; i <= n; i++ ){

        long long sum = 0;
        for( int k = 200; k >= 1; k-- ){
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][1] = sum;
            sum += dp[i-1][k][1];
            sum %= mod;
        }
        sum = 0;
        for( int k = 1; k <= 200 ; k++ ){
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][0] = sum;
            sum += dp[i-1][k][1] + dp[i-1][k][0];
            sum %= mod;
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][2] = dp[i-1][k][0] + dp[i-1][k][1] + dp[i-1][k][2] ;
        }
    }
    long long res = 0;
    for( int k = 1; k <= 200 ; k++ ){
        if( tab[n] == -1 || tab[n] == k ) {
            //cout << k << "kk " << endl;
            res += dp[n][k][1];
            res += dp[n][k][2];
            res %= mod;
        }

    }
    cout << res % mod << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define PII pair<int,int>
#define PPP pair<PII,PII>
#define PLL pair<long long, long long>
#define sz(x)int((x).size())
#define rep(i,b,e)for(int i=(b);i<(e);i++)
const long long inf = 3e12 + 10;

long long n;
const long long mod = 998244353;
long long dp[100001][201][2];
long long tab[100001];
int z = 200;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> tab[i];
    }
    if( n == 2 ){
        if( tab[1] == -1 && tab[2] == -1 ){
            cout << 200 << endl;
            return 0;
        }
        if( tab[1] == -1 || tab[2] == -1 ){
            cout << 1 << endl;
            return 0;
        }
        if( tab[1] == tab[2] ){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }

    for( int i = 1; i <= z; i++ ){
        if( tab[2] != -1 && tab[2] != i){
            continue;
        }
        for( int k = 1; k < i ; k++ ){
            if( tab[1] == -1 || tab[1] == k ){
                dp[2][i][0]++;
            }
        }
        if( tab[1] == -1 || tab[1] == i ){
            dp[2][i][1]++;
        }
    }

    for( int i = 3; i <= n; i++ ){

        long long sum = 0;
        for( int k = 200; k >= 1; k-- ){
            sum += dp[i-1][k][0] + dp[i-1][k][1];
            sum %= mod;
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][1] = sum;
        }
        sum = 0;
        for( int k = 1; k <= 200 ; k++ ){
            dp[i][k][0] = sum;
            if( tab[i] == -1 || tab[i] == k )
                sum += dp[i-1][k][1];
            sum %= mod;
        }
    }
    long long res = 0;
    for( int k = 1; k <= 200 ; k++ ){
        if( tab[n] == -1 || tab[n] == k ) {
            res += dp[n][k][0];
            res += dp[n-1][k][0] + dp[n-1][k][1];
            res %= mod;
        }

    }
    cout << res % mod << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define PII pair<int,int>
#define PPP pair<PII,PII>
#define PLL pair<long long, long long>
#define sz(x)int((x).size())
#define rep(i,b,e)for(int i=(b);i<(e);i++)
const long long inf = 3e12 + 10;

long long n;
const long long mod = 998244353;
long long dp[100001][201][3];
long long tab[100001];
int z = 200;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> tab[i];
    }
    if( n == 2 ){
        if( tab[1] == -1 && tab[2] == -1 ){
            cout << 200 << endl;
            return 0;
        }
        if( tab[1] == -1 || tab[2] == -1 ){
            cout << 1 << endl;
            return 0;
        }
        if( tab[1] == tab[2] ){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }

    for( int i = 1; i <= z; i++ ){
        if( tab[2] != -1 && tab[2] != i){
            continue;
        }
        for( int k = 1; k < i ; k++ ){
            if( tab[1] == -1 || tab[1] == k ){
                dp[2][i][0]++;
            }
        }
        if( tab[1] == -1 || tab[1] == i ){
            dp[2][i][2]++;
        }
    }

    for( int i = 3; i <= n; i++ ){

        long long sum = 0;
        for( int k = 200; k >= 1; k-- ){
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][1] = sum;
            sum += dp[i-1][k][1] + dp[i-1][k][2];
            sum %= mod;
        }
        sum = 0;
        for( int k = 1; k <= 200 ; k++ ){
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][0] = sum;
            sum += dp[i-1][k][1] + dp[i-1][k][0] + dp[i-1][k][2];
            sum %= mod;
            if( tab[i] == -1 || tab[i] == k )
                dp[i][k][2] = (dp[i-1][k][0] + dp[i-1][k][1] + dp[i-1][k][2])%mod ;
        }
    }
    long long res = 0;
    for( int k = 1; k <= 200 ; k++ ){
        if( tab[n] == -1 || tab[n] == k ) {
            //cout << k << "kk " << endl;
            res += dp[n][k][1];
            res += dp[n][k][2];
            res %= mod;
        }

    }
    cout << res % mod << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long
const int M = 1e5 + 1;
const int MOD = 998244353;
int n, dp[M][201][2], pre[M][201][2], A[M];

int32_t main()
{
    	#ifndef ONLINE_JUDGE
    		freopen("in.txt", "r", stdin);
	    	freopen("out.txt", "w", stdout);
	#endif
    	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
    	cin >> n;
    	for(int i = 1; i <= n; i++)	cin >> A[i];
    	if(A[1] == -1)
    	{
    		for(int j = 1; j <= 200; j++)
    			dp[1][j][0] = 1;
    	}
    	else		dp[1][A[1]][0] = 1;

    	for(int j = 1; j <= 200; j++)
    	{
    		pre[1][j][0] = (dp[1][j][0] + pre[1][j - 1][0]) % MOD;
    		pre[1][j][1] = (dp[1][j][1] + pre[1][j - 1][1]) % MOD;
    	}

    	for(int i = 2; i <= n; i++)
    	{
    		for(int j = 1; j <= 200; j++)
    		{
    			if(A[i] == -1 || A[i] == j)
    			{
    				int L = 1, R = j - 1;
    				dp[i][j][0] = (dp[i][j][0] + pre[i - 1][R][0] - pre[i - 1][L - 1][0]) % MOD;
    				dp[i][j][0] = (dp[i][j][0] + pre[i - 1][R][1] - pre[i - 1][L - 1][1]) % MOD;

    				// for third state to be zero only jth number can be used since agar j se bada
    				// number liya toh (i - 1)th position ke dono neighbours chote ho jayenge
    				dp[i][j][1] = (dp[i][j][1] + pre[i - 1][j][0] - pre[i - 1][j - 1][0]) % MOD;

    				L = j, R = 200;
    				// last wala element iske equal hoga ya bada hoga aur uske last wala element bada hoga
    				// toh condition satisfied
    				dp[i][j][1] = (dp[i][j][1] + pre[i - 1][R][1] - pre[i - 1][L - 1][1]) % MOD;
    			}
    		}
    		for(int j = 1; j <= 200; j++)
    		{
    			pre[i][j][0] = (dp[i][j][0] + pre[i][j - 1][0]) % MOD;
    			pre[i][j][1] = (dp[i][j][1] + pre[i][j - 1][1]) % MOD;
    		}
    	}
    	int ans = 0;
    	for(int j = 1; j <= 200; j++)
    		ans = (ans + dp[n][j][1]) % MOD;
    	cout << ans << endl;
    	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
const int MOD = 998244353;
int n, dp[M][201][2], pre[M][201][2], A[M];

int32_t main()
{
    	#ifndef ONLINE_JUDGE
    		freopen("in.txt", "r", stdin);
	    	freopen("out.txt", "w", stdout);
	#endif
    	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
    	cin >> n;
    	for(int i = 1; i <= n; i++)	cin >> A[i];
    	if(A[1] == -1)
    	{
    		for(int j = 1; j <= 200; j++)
    			dp[1][j][0] = 1;
    	}
    	else		dp[1][A[1]][0] = 1;

    	for(int j = 1; j <= 200; j++)
    	{
    		pre[1][j][0] = (dp[1][j][0] + pre[1][j - 1][0]) % MOD;
    		pre[1][j][1] = (dp[1][j][1] + pre[1][j - 1][1]) % MOD;
    	}

    	for(int i = 2; i <= n; i++)
    	{
    		for(int j = 1; j <= 200; j++)
    		{
    			if(A[i] == -1 || A[i] == j)
    			{
    				int L = 1, R = j - 1;
    				dp[i][j][0] = (dp[i][j][0] + (pre[i - 1][R][0] - pre[i - 1][L - 1][0] + MOD) % MOD) % MOD;

    				dp[i][j][0] = (dp[i][j][0] + (pre[i - 1][R][1] - pre[i - 1][L - 1][1] + MOD) % MOD) % MOD;

    				// for third state to be zero only jth number can be used since agar j se bada
    				// number liya toh (i - 1)th position ke dono neighbours chote ho jayenge
    				dp[i][j][1] = (dp[i][j][1] + (pre[i - 1][j][0] - pre[i - 1][j - 1][0] + MOD) % MOD) % MOD;

    				L = j, R = 200;
    				// last wala element iske equal hoga ya bada hoga aur uske last wala element bada hoga
    				// toh condition satisfied
    				dp[i][j][1] = (dp[i][j][1] + (pre[i - 1][R][1] - pre[i - 1][L - 1][1] + MOD) % MOD) % MOD;
    			}
    		}
    		for(int j = 1; j <= 200; j++)
    		{
    			pre[i][j][0] = (dp[i][j][0] + pre[i][j - 1][0]) % MOD;
    			pre[i][j][1] = (dp[i][j][1] + pre[i][j - 1][1]) % MOD;
    		}
    	}
    	cout << pre[n][200][1] << endl;
    	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 1;
const int MOD = 998244353;
int n, dp[M][201][2], pre[M][201][2], A[M];

int32_t main()
{
    	#ifndef ONLINE_JUDGE
    		freopen("in.txt", "r", stdin);
	    	freopen("out.txt", "w", stdout);
	#endif
    	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
    	cin >> n;
    	for(int i = 1; i <= n; i++)	cin >> A[i];
    	if(A[1] == -1)
    	{
    		for(int j = 1; j <= 200; j++)
    			dp[1][j][0] = 1;
    	}
    	else		dp[1][A[1]][0] = 1;

    	for(int j = 1; j <= 200; j++)
    	{
    		pre[1][j][0] = (dp[1][j][0] + pre[1][j - 1][0]) % MOD;
    		pre[1][j][1] = (dp[1][j][1] + pre[1][j - 1][1]) % MOD;
    	}

    	for(int i = 2; i <= n; i++)
    	{
    		for(int j = 1; j <= 200; j++)
    		{
    			if(A[i] == -1 || A[i] == j)
    			{
    				int L = 1, R = j - 1;
    				dp[i][j][0] = (dp[i][j][0] + pre[i - 1][R][0] - pre[i - 1][L - 1][0]) % MOD;
    				dp[i][j][0] = (dp[i][j][0] + pre[i - 1][R][1] - pre[i - 1][L - 1][1]) % MOD;

    				// for third state to be zero only jth number can be used since agar j se bada
    				// number liya toh (i - 1)th position ke dono neighbours chote ho jayenge
    				dp[i][j][1] = (dp[i][j][1] + pre[i - 1][j][0] - pre[i - 1][j - 1][0]) % MOD;

    				L = j, R = 200;
    				// last wala element iske equal hoga ya bada hoga aur uske last wala element bada hoga
    				// toh condition satisfied
    				dp[i][j][1] = (dp[i][j][1] + pre[i - 1][R][1] - pre[i - 1][L - 1][1]) % MOD;
    			}
    		}
    		for(int j = 1; j <= 200; j++)
    		{
    			pre[i][j][0] = (dp[i][j][0] + pre[i][j - 1][0]) % MOD;
    			pre[i][j][1] = (dp[i][j][1] + pre[i][j - 1][1]) % MOD;
    		}
    	}
    	int ans = 0;
    	for(int j = 1; j <= 200; j++)
    		ans = (ans + dp[n][j][1]) % MOD;
    	cout << ans << endl;
    	return 0;
}