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

data = []
line1 = True
asterisks = []
for line in sys.stdin:
    if line1:
        line1 = False
        dim = line[:-1].split(" ")
    else:
        row = []
        for i, c in enumerate(line):
            if c == "*":
                row.append(i+1)
        asterisks.append(row)

sum = 0
for row in asterisks:
    if len(row) >= 2:
        vertices = []
        for num in row:
            counter = 0
            for r in asterisks:
                if num in r:
                    counter += 1
            vertices.append(counter-1)
        for i, item in enumerate(row):
            sum += vertices[i] * (len(row) - 1)
print(sum)
