You are given a *n* × *m* field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle).
The first line contains two positive integer numbers *n* and *m* (1 ≤ *n*, *m* ≤ 1000). The following *n* lines consist of *m* characters each, describing the field. Only '.' and '*' are allowed.
import sys
from array import array  # noqa: F401


def input():
    return sys.stdin.buffer.readline().decode('utf-8')


n, m = map(int, input().split())
a = ([[0] * (m + 2)]
     + [[0] + list(1 if c == '*' else 0 for c in input().rstrip()) + [0] for _ in range(n)]
     + [[0] * (m + 2)])

lr = [[0] * (m + 2) for _ in range(n + 2)]
ud = [[0] * (m + 2) for _ in range(n + 2)]

for i in range(1, n + 1):
    for j in range(1, m + 2):
        lr[i][j] = lr[i][j - 1] + a[i][j]

for j in range(1, m + 1):
    for i in range(1, n + 2):
        ud[i][j] = ud[i - 1][j] + a[i][j]

ans = 0
for i in range(1, n + 1):
    for j in range(1, m + 1):
        if a[i][j]:
            l, r, u, d = lr[i][j - 1], lr[i][-1] - lr[i][j], ud[i - 1][j], ud[-1][j] - ud[i][j]
            ans += u * r + r * d + d * l + l * u

print(ans)
