#include <iostream>
#include <vector>
#define int long long
using namespace std;
constexpr int MAXN(3007);
vector <int> lmx, lmy;
int xx[] = {0, 1};
int yy[] = {1, 0};
char ch[MAXN][MAXN];
int a[MAXN][MAXN], b[MAXN][MAXN], c[MAXN][MAXN], d[MAXN][MAXN];
int qx[MAXN * MAXN], qy[MAXN * MAXN], head, tail;
int n, m, ept, jiao, njiao;
long long ans;
inline void read(int &temp) { cin >> temp; }
inline void bfs1() {
head = 1, tail = 0;
qx[++tail] = 1, qy[tail] = 1, a[1][1] = 1;
while (head <= tail) {
int nx = qx[head], ny = qy[head++];
for (int i(0); i < 2; ++i) {
int tx = nx + xx[i], ty = ny + yy[i];
if (tx > n || ty > m || ch[tx][ty] == '*') continue;
if (!a[tx][ty]) qx[++tail] = tx, qy[tail] = ty;
a[tx][ty] = 1;
}
}
}
inline void bfs2() {
head = 1, tail = 0;
qx[++tail] = n, qy[tail] = m, b[n][m] = 1;
while (head <= tail) {
int nx = qx[head], ny = qy[head++];
for (int i(0); i < 2; ++i) {
int tx = nx - xx[i], ty = ny - yy[i];
if (tx < 1 || ty < 1 || ch[tx][ty] == '*') continue;
if (!b[tx][ty]) qx[++tail] = tx, qy[tail] = ty;
b[tx][ty] = 1;
}
}
}
void leftmost(int x, int y, int dt) {
if (dt) ++c[x][y], lmx.emplace_back(x), lmy.emplace_back(y);
if (d[x][y] && !c[x][y]) ++njiao;
if (x == n && y == m) return ;
if (b[x + 1][y]) return leftmost(x + 1, y, dt);
return leftmost(x, y + 1, dt);
}
void rightmost(int x, int y) {
++d[x][y];
if (c[x][y]) ++jiao;
if (x == n && y == m) return ;
if (b[x][y + 1]) return rightmost(x, y + 1);
return rightmost(x + 1, y);
}
void nlm(int x, int y) {
if (d[x][y] && !c[x][y]) ++njiao;
if (x == 1 && y == 1) return ;
if (a[x][y - 1]) return nlm(x, y - 1);
return nlm(x - 1, y);
}
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
read(n), read(m);
for (int i(1); i <= n; ++i)
for (int j(1); j <= m; ++j) cin >> ch[i][j];
for (int i(1); i <= n; ++i)
for (int j(1); j <= m; ++j) if (ch[i][j] == '.') ++ept;
bfs1(), bfs2();
if (!a[n][m]) return cout << max(ept * (ept - 1) / 2, 0) << endl, 0;
leftmost(1, 1, 1), rightmost(1, 1);
ans = jiao * (ept - jiao) + jiao * (jiao - 1) / 2;
for (int i(0); i < (int)lmx.size(); ++i) {
int x = lmx[i], y = lmy[i];
if (d[x][y]) continue;
njiao = 0;
for (int j(1); x - j >= 1 && y + j <= m; ++j) {
if (a[x - j][y + j] && b[x - j][y + j]) {
leftmost(x - j, y + j, 0), nlm(x - j, y + j);
ans += njiao - d[x - j][y + j];
break;
}
}
}
cout << ans << endl;
return 0;
}