#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <cassert>

#define dig(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template <class TAT>
inline void read(TAT &a)
{
	static char cc;
	static bool f;
	while ((cc = getchar()) != '-' && (cc < '0' || cc > '9'));
	if (cc == '-') f = 1, a = 0;
	else f = 0, a = cc - '0';
	while ((cc = getchar()) >= '0' && cc <= '9') a = a * 10 + cc - '0';
	if (f) a = -a;
}
template <class TAT>
inline void write(TAT a)
{
	static char cc[27];
	static int ct;
	if (a == 0) {
		putchar('0');
		return;
	}
	if (a < 0) {
		a = -a;
		putchar('-');
	}
	ct = 0;
	while (a) cc[++ct] = a % 10 + '0', a /= 10;
	while (ct) putchar(cc[ct--]);
}
template <class TAT>
inline void Ckmin(TAT &a, const TAT &b)
{
	if (a > b) a = b;
}
template <class TAT>
inline void Ckmax(TAT &a, const TAT &b)
{
	if (a < b) a = b;
}
void begin()
{
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
}
void end()
{
	fclose(stdin);
	fclose(stdout);
}

typedef long long LL;

const int maxn = 103;

int n, m, cx, cy;
short Ans;
char mat[maxn][maxn];
short f[maxn][maxn][maxn][maxn];
short h[maxn][maxn];
short w[maxn][maxn];

void Init()
{
    read(n), read(m);
    for (int i = 1; i <= n; ++i) {
        scanf("%s", mat[i] + 1);
        for (int j = 1; j <= m; ++j) {
            if (mat[i][j] == 'E') {
                cx = i;
                cy = j;
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        h[i][0] = 0;
        for (int j = 1; j <= m; ++j) {
            h[i][j] = h[i][j - 1] + (mat[i][j] == 'o');
        }
    }
    for (int i = 1; i <= m; ++i) {
        w[i][0] = 0;
        for (int j = 1; j <= n; ++j) {
            w[i][j] = w[i][j - 1] + (mat[j][i] == 'o');
        }
    }
}

short GetH(int i, int x, int y)
{
    if (x > y) return 0;
    return h[i][y] - h[i][x - 1];
}

short GetL(int i, int x, int y)
{
    if (x > y) return 0;
    return w[i][y] - w[i][x - 1];
}

void Solve()
{
    int Leftbound, Rightbound, Upbound, Downbound;
    int x, y;
    Leftbound = cy - 1;
    Rightbound = m - cy;
    Upbound = cx - 1;
    Downbound = n - cx;
    for (int l = 0; l <= Leftbound; ++l) {
        for (int r = 0; r <= Rightbound; ++r) {
            for (int u = 0; u <= Upbound; ++u) {
                for (int d = 0; d <= Downbound; ++d) {
                    Ckmax(Ans, f[l][r][u][d]);
                    if (r + l < cy - 1) {//Left!!
                        x = cx - u; y = cx + d;
                        Ckmax(x, d + 1); Ckmin(y, n - u);
                        Ckmax(f[l + 1][r][u][d], (short)(f[l][r][u][d] + GetL(cy - l - 1, x, y)));
                    }
                    if (r + l + cy < m) {//Right!!
                        x = cx - u; y = cx + d;
                        Ckmax(x, d + 1); Ckmin(y, n - u);
                        Ckmax(f[l][r + 1][u][d], (short)(f[l][r][u][d] + GetL(cy + r + 1, x, y)));
                    }
                    if (u + d < cx - 1) {//Up!!
                        x = cy - l; y = cy + r;
                        Ckmax(x, r + 1); Ckmin(y, m - l);
                        Ckmax(f[l][r][u + 1][d], (short)(f[l][r][u][d] + GetH(cx - u - 1, x, y)));
                    }
                    if (u + d + cx < n) {//Down!!
                        x = cy - l; y = cy + r;
                        Ckmax(x, r + 1); Ckmin(y, m - l);
                        Ckmax(f[l][r][u][d + 1], (short)(f[l][r][u][d] + GetH(cx + d + 1, x, y)));
                    }
                }
            }
        }
    }
    /*
    for (int l = 0; l <= Leftbound; ++l) {
        for (int r = 0; r <= Rightbound; ++r) {
            for (int u = 0; u <= Upbound; ++u) {
                for (int d = 0; d <= Downbound; ++d) {
                    printf("%d %d %d %d :  %d\n", l, r, u, d, f[l][r][u][d]);
                }
            }
        }
    }
    */
}

void Put()
{
    write(Ans);
    putchar('\n');
}

int main()
{
    Init();
    Solve();
    Put();
	return 0;
}


Measured memory_bytes: 49920