#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e3 + 10;
const long long mod = 1e9 + 7;
inline long long bpow(long long t, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * t) % mod;
    t = (t * t) % mod, n >>= 1;
  }
  return ans;
}
long long fact[MAX_N], ifact[MAX_N];
inline long long c(long long n, long long k) {
  if (k > n || k < 0) return 0;
  return (fact[n] * ifact[k] % mod * ifact[n - k]) % mod;
}
inline void get_fact() {
  fact[0] = 1;
  ifact[0] = 1;
  for (long long i = 1; i < MAX_N; i++)
    fact[i] = (fact[i - 1] * i) % mod, ifact[i] = bpow(fact[i], mod - 2);
}
char a[MAX_N][MAX_N];
int dp[4][MAX_N][MAX_N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(0);
  get_fact();
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      dp[0][i][j] = dp[0][i - 1][j] + (a[i][j] == '*');
      dp[1][i][j] = dp[1][i][j - 1] + (a[i][j] == '*');
    }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      dp[2][i][j] = dp[2][i + 1][j] + (a[i][j] == '*');
      dp[3][i][j] = dp[3][i][j + 1] + (a[i][j] == '*');
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int d[] = {dp[0][n][j] - dp[0][i][j], dp[1][i][m] - dp[1][i][j],
                 dp[2][1][j] - dp[2][i][j], dp[3][i][1] - dp[3][i][j]};
      if (a[i][j] == '*')
        ans += d[0] * d[1] + d[1] * d[2] + d[2] * d[3] + d[3] * d[0];
    }
  }
  cout << ans;
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

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).

Input

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.

Output

Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

2 2
**
*.


Output

1


Input

3 4
*..*
.**.
*.**


Output

9

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e3 + 10;
const long long mod = 1e9 + 7;
inline long long bpow(long long t, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * t) % mod;
    t = (t * t) % mod, n >>= 1;
  }
  return ans;
}
long long fact[MAX_N], ifact[MAX_N];
inline long long c(long long n, long long k) {
  if (k > n || k < 0) return 0;
  return (fact[n] * ifact[k] % mod * ifact[n - k]) % mod;
}
inline void get_fact() {
  fact[0] = 1;
  ifact[0] = 1;
  for (long long i = 1; i < MAX_N; i++)
    fact[i] = (fact[i - 1] * i) % mod, ifact[i] = bpow(fact[i], mod - 2);
}
char a[MAX_N][MAX_N];
int dp[4][MAX_N][MAX_N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(0);
  get_fact();
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      dp[0][i][j] = dp[0][i - 1][j] + (a[i][j] == '*');
      dp[1][i][j] = dp[1][i][j - 1] + (a[i][j] == '*');
    }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      dp[2][i][j] = dp[2][i + 1][j] + (a[i][j] == '*');
      dp[3][i][j] = dp[3][i][j + 1] + (a[i][j] == '*');
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int d[] = {dp[0][n][j] - dp[0][i][j], dp[1][i][m] - dp[1][i][j],
                 dp[2][1][j] - dp[2][i][j], dp[3][i][1] - dp[3][i][j]};
      if (a[i][j] == '*')
        ans += d[0] * d[1] + d[1] * d[2] + d[2] * d[3] + d[3] * d[0];
    }
  }
  cout << ans;
}

```