A tourist wants to visit country Zeydabad for Zbazi (a local game in Zeydabad).

The country Zeydabad is a rectangular table consisting of *n* rows and *m* columns. Each cell on the country is either 'z' or '.'.

The tourist knows this country is named Zeydabad because there are lots of ''Z-pattern"s in the country. A ''Z-pattern" is a square which anti-diagonal is completely filled with 'z' and its upper and lower rows are also completely filled with 'z'. All other cells of a square can be arbitrary.

Note that a ''Z-pattern" can consist of only one cell (see the examples).

So he wants to count the number of ''Z-pattern"s in the country (a necessary skill for Zbazi).

Now your task is to help tourist with counting number of ''Z-pattern"s.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
The first line contains two integers *n*, *m* (1 ≤ *n*, *m* ≤ 3000) — the number of rows and columns respectively.

Each of the next *n* lines contains *m* characters 'z' or '.' — the description of Zeydabad.
none
4 4
zzzz
zzz.
.z..
zzzz
16
1 4
z.z.
2
2 2
zz
zz
5
#!/usr/bin/env python3

from __future__ import division, print_function

def least_significant_bit(i):
    return ((i) & -(i))

class FenwickTree():
    def __init__(self, n):
        # 1-indexed
        self.n = n + 1 
        self.data = [0,] * self.n
    
    def add(self, index, value):
        # 1-indexed
        i = index + 1
        while i < self.n:
            self.data[i] += value
            i += least_significant_bit(i)
        
    def prefix_sum(self, index):
        # 1-indexed
        i = index + 1
        result = 0
        while i > 0:
            result += self.data[i]
            i -= least_significant_bit(i)
        return result
    
    def range_sum(self, start, end):
        return self.prefix_sum(end) - self.prefix_sum(start-1)

def solver(ifs):
    n, m = list(map(int, ifs.readline().split()))
    grid = [None, ] * (n * m)
    for i in range(n):
        row = ifs.readline().strip()
        grid[i * m: (i+1) * m] = [(c=='z') for c in row]
    left = [None, ] * (n * m)
    right = [None, ] * (n * m)
    for i in range(n):
        row = grid[i * m: (i+1) * m]
        left[i*m+0] = 1 * row[0]
        for j in range(1, m):
            left[i*m+j] = left[i*m+j-1] + 1 if row[j] else 0
        right[i*m+m-1] = 1 * row[m-1]
        for j in range(m-2, -1, -1):
            right[i*m+j] = right[i*m+j+1] + 1 if row[j] else 0
    res = 0
    for i, j in [(0, a) for a in range(m)] + [(b, m-1) for b in range(1, n)]:
        lend = min(n-i, j+1)
        d = [1*grid[(i+pos)*m+j-pos] for pos in range(lend)]
        for pos in range(lend-2, -1, -1):
            d[pos] = d[pos+1] + 1 if d[pos] else 0
        tbr = [ [] for _ in range(lend + 1)]
        ft = FenwickTree(lend)
        for pos, val in enumerate(d):
            while tbr[pos]:
                ft.add(tbr[pos].pop(), -1)
            c = min(val, left[(i+pos)*m + j-pos])
            if c > 0:
                ft.add(pos, 1)
                tbr[pos + c].append(pos)
            d = right[(i+pos)*m + j-pos]
            if d > 0:
                res += ft.range_sum(max(0,pos-d+1), pos)
    print(res)

def main():
    import sys
    if sys.version_info.major == 3:
        from io import StringIO as StreamIO
    else:
         from io import BytesIO as StreamIO
    
    with StreamIO(sys.stdin.read()) as ifs, StreamIO() as ofs:
        _stdout = sys.stdout
        sys.stdout = ofs
        solver(ifs)
        sys.stdout = _stdout
        sys.stdout.write(ofs.getvalue())
    return 0

if __name__ == '__main__':
    main()
