#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

int n, m;
char a[105][105];
int row[105][105], col[105][105];
int x, y;

int dp[105][105][105][105];

int getCol(int y, int x, int x2) {
    if (x > x2)
        return 0;
    return col[y][x2] - col[y][x - 1];
}

int getRow(int x, int y, int y2) {
    if (y > y2)
        return 0;
    return row[x][y2] - row[x][y - 1];
}

void upd(int &x, const int &nw) {
    x = max(x, nw);
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            if (a[i][j] == 'E')
                x = i, y = j;
        }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            row[i][j] = row[i][j - 1] + (a[i][j] == 'o');
        }
    }
    for (int j = 1; j <= m; j++)
        for (int i = 1; i <= n; i++) {
            col[j][i] = col[j][i - 1] + (a[i][j] == 'o');
        }
    int ans = 0;
    for (int l = 0; y - l > 0; l++)
        for (int r = 0; y + r <= m; r++)
            for (int u = 0; x - u > 0; u++)
                for (int d = 0; x + d <= n; d++) {
                    int &now = dp[l][r][u][d];
                    ans = max(ans, now);
                    
                    int add = 0;
                    if (y - l - 1 > r && y - l - 1 <= m - l)
                        add = getCol(y - l - 1, max(d + 1, x - u), min(n - u, x + d));
                    upd(dp[l + 1][r][u][d], now + add);
                    
                    add = 0;
                    if (y + r + 1 <= m - l && y + r + 1 > r)
                        add = getCol(y + r + 1, max(d + 1, x - u), min(n - u, x + d));
                    upd(dp[l][r + 1][u][d], now + add);
                    
                    add = 0;
                    if (x - u - 1 > d && x - u - 1 <= n - u)
                        add = getRow(x - u - 1, max(r + 1, y - l), min(m - l, y + r));
                    upd(dp[l][r][u + 1][d], now + add);
                    
                    add = 0;
                    if (x + d + 1 <= n - u && x + d + 1 > d)
                        add = getRow(x + d + 1, max(r + 1, y - l), min(m - l, y + r));
                    upd(dp[l][r][u][d + 1], now + add);
                }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 242944