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


readline = sys.stdin.readline
N, M = 0, 0
matrix = []

def read_input():
    global N, M, matrix
    N, M = [int(w) for w in readline().split()]
    matrix = [[0] * M for _ in range(N)]
    for i in range(N):
        line = readline().strip()
        for j in range(M):
            if line[j] == '*':
                matrix[i][j] = 1

def solve()->int:
    row_cnt = [0] * N
    col_cnt = [0] * M
    for r in range(N):
        for c in range(M):
            row_cnt[r] += matrix[r][c]
            col_cnt[c] += matrix[r][c]
    result = 0
    for r in range(N):
        for c in range(M):
            if matrix[r][c] == 1:
                result += (row_cnt[r] - 1) * (col_cnt[c] - 1)
    return result

def write_output(result: int):
    print(result)


read_input()
write_output(solve())
