import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



import numpy as np

import itertools



H,W = list(map(int,readline().split()))

S = (np.frombuffer(read(),dtype='S1')==b'#').reshape(H,-1)[:,:W].astype(np.int64)



# pad_width

p = min(H,W)+1



S = np.pad(S,(p,p),'constant')



def F(S,H,W):

    # L,Uに頂点があって、RDに第3の頂点がある場合。

    # Rは数えずDだけ数えておく

    cnt = 0

    diag = np.zeros((H+p,W+p),np.int64)

    diag[:H,:W] += S[p:-p,p:-p]

    for n in range(1,H+p):

        diag[n,:W] += diag[n-1,1:W+1]

    for n in range(1,p):

        cnt += (S[1+p:H+1+p,1-n+p:W+1-n+p] * S[1-n+p:H+1-n+p,1+p:W+1+p] * (diag[1+n:H+1+n,1:W+1]-diag[1:H+1,1+n:W+1+n])).sum()

    return cnt



x = []

x.append(F(S,H,W))

S = S.T[::-1,:] # 90度回転

x.append(F(S,W,H))

S = S.T[::-1,:] # 90度回転

x.append(F(S,H,W))

S = S.T[::-1,:] # 90度回転

x.append(F(S,W,H))



answer = sum(x)

print(answer)



import sys

b=sys.stdin.buffer

import numpy as np

H,W=list(map(int,b.readline().split()));p=min(H,W)+1

S=np.pad((np.frombuffer(b.read(),dtype='S1')==b'#').reshape(H,-1)[:,:W].astype(int),(p,p),'constant')

a=0

for _ in[0]*4:

  d=S[p:,p:].copy()

  for n in range(H+p):d[n,:W]+=d[n-1,1:W+1]

  for n in range(p):a+=(S[1+p:H+1+p,1-n+p:W+1-n+p]*S[1-n+p:H+1-n+p,1+p:W+1+p]*(d[1+n:H+1+n,1:W+1]-d[1:H+1,1+n:W+1+n])).sum()

  S = S.T[::-1,:];H,W=W,H

print(a)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
import numpy as np
import itertools

H, W = list(map(int, readline().split()))
S = (np.frombuffer(read(), dtype="S1") == b"#").reshape(H, -1)[:, :W].astype(np.int64)
# pad_width
p = min(H, W) + 1
S = np.pad(S, (p, p), "constant")


def F(S, H, W):
    # L,Uに頂点があって、RDに第3の頂点がある場合。
    # Rは数えずDだけ数えておく
    cnt = 0
    diag = np.zeros((H + p, W + p), np.int64)
    diag[:H, :W] += S[p:-p, p:-p]
    for n in range(1, H + p):
        diag[n, :W] += diag[n - 1, 1 : W + 1]
    for n in range(1, p):
        cnt += (
            S[1 + p : H + 1 + p, 1 - n + p : W + 1 - n + p]
            * S[1 - n + p : H + 1 - n + p, 1 + p : W + 1 + p]
            * (diag[1 + n : H + 1 + n, 1 : W + 1] - diag[1 : H + 1, 1 + n : W + 1 + n])
        ).sum()
    return cnt


x = []
x.append(F(S, H, W))
S = S.T[::-1, :]  # 90度回転
x.append(F(S, W, H))
S = S.T[::-1, :]  # 90度回転
x.append(F(S, H, W))
S = S.T[::-1, :]  # 90度回転
x.append(F(S, W, H))
answer = sum(x)
print(answer)

import sys

b = sys.stdin.buffer
import numpy as np

H, W = list(map(int, b.readline().split()))
p = min(H, W) + 1
S = np.pad(
    (np.frombuffer(b.read(), dtype="S1") == b"#").reshape(H, -1)[:, :W].astype(int),
    (p, p),
    "constant",
)
a = 0
for _ in [0] * 4:
    d = S[p:, p:].copy()
    for n in range(H + p):
        d[n, :W] += d[n - 1, 1 : W + 1]
    for n in range(p):
        a += (
            S[1 + p : H + 1 + p, 1 - n + p : W + 1 - n + p]
            * S[1 - n + p : H + 1 - n + p, 1 + p : W + 1 + p]
            * (d[1 + n : H + 1 + n, 1 : W + 1] - d[1 : H + 1, 1 + n : W + 1 + n])
        ).sum()
    S = S.T[::-1, :]
    H, W = W, H
print(a)

-read = sys.stdin.buffer.read -readline = sys.stdin.buffer.readline -readlines = sys.stdin.buffer.readlines -sys.setrecursionlimit(10**7) +b = sys.stdin.buffer -import itertools -H, W = list(map(int, readline().split())) -S = (np.frombuffer(read(), dtype="S1") == b"#").reshape(H, -1)[:, :W].astype(np.int64) -# pad_width +H, W = list(map(int, b.readline().split())) -S = np.pad(S, (p, p), "constant") - - -def F(S, H, W): -    # L,Uに頂点があって、RDに第3の頂点がある場合。 -    # Rは数えずDだけ数えておく -    cnt = 0 -    diag = np.zeros((H + p, W + p), np.int64) -    diag[:H, :W] += S[p:-p, p:-p] -    for n in range(1, H + p): -        diag[n, :W] += diag[n - 1, 1 : W + 1] -    for n in range(1, p): -        cnt += ( +S = np.pad( +    (np.frombuffer(b.read(), dtype="S1") == b"#").reshape(H, -1)[:, :W].astype(int), +    (p, p), +    "constant", +) +a = 0 +for _ in [0] * 4: +    d = S[p:, p:].copy() +    for n in range(H + p): +        d[n, :W] += d[n - 1, 1 : W + 1] +    for n in range(p): +        a += ( -            * (diag[1 + n : H + 1 + n, 1 : W + 1] - diag[1 : H + 1, 1 + n : W + 1 + n]) +            * (d[1 + n : H + 1 + n, 1 : W + 1] - d[1 : H + 1, 1 + n : W + 1 + n]) -    return cnt - - -x = [] -x.append(F(S, H, W)) -S = S.T[::-1, :]  # 90度回転 -x.append(F(S, W, H)) -S = S.T[::-1, :]  # 90度回転 -x.append(F(S, H, W)) -S = S.T[::-1, :]  # 90度回転 -x.append(F(S, W, H)) -answer = sum(x) -print(answer) +    S = S.T[::-1, :] +    H, W = W, H +print(a)