#include <bits/stdc++.h>
using namespace std;
struct iii {
  int a, b, c;
  iii() {}
  iii(int a, int b, int c) : a(a), b(b), c(c) {}
  bool operator<(const iii& e) const {
    return a < e.a || a == e.a && (b < e.b || b == e.b && c < e.c);
  }
};
struct Scanner {
  Scanner& operator>>(int& x) {
    scanf("%d", &x);
    return *this;
  }
  Scanner& operator>>(double& x) {
    scanf("%lf", &x);
    return *this;
  }
  Scanner& operator>>(char* x) {
    scanf("%s", x);
    return *this;
  }
  Scanner& operator>>(pair<int, int>& x) {
    scanf("%d%d", &x.first, &x.second);
    return *this;
  }
  Scanner& operator>>(pair<double, double>& x) {
    scanf("%lf%lf", &x.first, &x.second);
    return *this;
  }
} in;
template <typename T>
T sq(const T& x) {
  return x * x;
}
template <typename T>
void minl(T& a, const T& b) {
  if (a > b) a = b;
}
template <typename T>
void maxl(T& a, const T& b) {
  if (a < b) a = b;
}
template <typename T>
void usort(vector<T>& a) {
  sort((a).begin(), (a).end());
  a.erase(unique((a).begin(), (a).end()), a.end());
}
template <typename T>
int index(const vector<T>& a, const T& x) {
  return lower_bound((a).begin(), (a).end(), x) - a.begin();
}
pair<int, int> operator+(const pair<int, int>& a, const pair<int, int>& b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int>& a, const pair<int, int>& b) {
  return pair<int, int>(a.first - b.first, a.second - b.second);
}
long long cross(const pair<int, int>& a, const pair<int, int>& b) {
  return (long long)a.first * b.second - (long long)b.first * a.second;
}
const int N = 1000 + 4;
int n, m;
long long ans;
char s[N][N];
int up[N][N];
int down[N][N];
int lf[N][N];
int rt[N][N];
void york() {
  in >> n >> m;
  for (int i = 0; i < n; i++) in >> s[i];
  for (int j = 0; j < m; j++) {
    int t = 0;
    for (int i = 0; i < n; i++) {
      if (s[i][j] != '*') continue;
      up[i][j] = t++;
    }
  }
  for (int j = 0; j < m; j++) {
    int t = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i][j] != '*') continue;
      down[i][j] = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = 0; j < m; j++) {
      if (s[i][j] != '*') continue;
      lf[i][j] = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = m - 1; j >= 0; j--) {
      if (s[i][j] != '*') continue;
      rt[i][j] = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] != '*') continue;
      ans += up[i][j] * lf[i][j];
      ans += up[i][j] * rt[i][j];
      ans += down[i][j] * lf[i][j];
      ans += down[i][j] * rt[i][j];
    }
  }
  cout << ans << endl;
}
int main() {
  york();
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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;
struct iii {
  int a, b, c;
  iii() {}
  iii(int a, int b, int c) : a(a), b(b), c(c) {}
  bool operator<(const iii& e) const {
    return a < e.a || a == e.a && (b < e.b || b == e.b && c < e.c);
  }
};
struct Scanner {
  Scanner& operator>>(int& x) {
    scanf("%d", &x);
    return *this;
  }
  Scanner& operator>>(double& x) {
    scanf("%lf", &x);
    return *this;
  }
  Scanner& operator>>(char* x) {
    scanf("%s", x);
    return *this;
  }
  Scanner& operator>>(pair<int, int>& x) {
    scanf("%d%d", &x.first, &x.second);
    return *this;
  }
  Scanner& operator>>(pair<double, double>& x) {
    scanf("%lf%lf", &x.first, &x.second);
    return *this;
  }
} in;
template <typename T>
T sq(const T& x) {
  return x * x;
}
template <typename T>
void minl(T& a, const T& b) {
  if (a > b) a = b;
}
template <typename T>
void maxl(T& a, const T& b) {
  if (a < b) a = b;
}
template <typename T>
void usort(vector<T>& a) {
  sort((a).begin(), (a).end());
  a.erase(unique((a).begin(), (a).end()), a.end());
}
template <typename T>
int index(const vector<T>& a, const T& x) {
  return lower_bound((a).begin(), (a).end(), x) - a.begin();
}
pair<int, int> operator+(const pair<int, int>& a, const pair<int, int>& b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int>& a, const pair<int, int>& b) {
  return pair<int, int>(a.first - b.first, a.second - b.second);
}
long long cross(const pair<int, int>& a, const pair<int, int>& b) {
  return (long long)a.first * b.second - (long long)b.first * a.second;
}
const int N = 1000 + 4;
int n, m;
long long ans;
char s[N][N];
int up[N][N];
int down[N][N];
int lf[N][N];
int rt[N][N];
void york() {
  in >> n >> m;
  for (int i = 0; i < n; i++) in >> s[i];
  for (int j = 0; j < m; j++) {
    int t = 0;
    for (int i = 0; i < n; i++) {
      if (s[i][j] != '*') continue;
      up[i][j] = t++;
    }
  }
  for (int j = 0; j < m; j++) {
    int t = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i][j] != '*') continue;
      down[i][j] = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = 0; j < m; j++) {
      if (s[i][j] != '*') continue;
      lf[i][j] = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = m - 1; j >= 0; j--) {
      if (s[i][j] != '*') continue;
      rt[i][j] = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] != '*') continue;
      ans += up[i][j] * lf[i][j];
      ans += up[i][j] * rt[i][j];
      ans += down[i][j] * lf[i][j];
      ans += down[i][j] * rt[i][j];
    }
  }
  cout << ans << endl;
}
int main() {
  york();
  return 0;
}

```