#include <bits/stdc++.h>

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define OF(i,a,b) for (int (i) = (a)-1; (i) >= (b); --(i))
#define SZ(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

int H, W;
char gr[105][105];
int cum[105][105];
int dp[2][105][105][105];

int exX, exY;
int maxL, maxU, maxR, maxD;


int getRect (int l, int u, int r, int d) {
    if (u == 0 && l == 0) return cum[d][r];
    if (u == 0) return cum[d][r] - cum[d][l-1];
    if (l == 0) return cum[d][r] - cum[u-1][r];
    return cum[d][r] - cum[d][l-1] - cum[u-1][r] + cum[u-1][l-1];
}

int getInt (int l1, int u1, int r1, int d1, int l2, int u2, int r2, int d2, bool isFlag = false) {
    int nL = max (l1,l2);
    int nU = max (u1,u2);
    int nR = min (r1,r2);
    int nD = min (d1,d2);
    if (nL < 0 || nR >= W || nU < 0 || nD >= H) return 0;
    if (nD < nU || nR < nL) return 0;
    //if (isFlag) printf ("%d %d %d %d %d %d %d %d %d\n", l1, u1, r1, d1, l2, u2 ,r2, d2, getRect (nL, nU, nR, nD));
    return getRect (nL, nU, nR, nD);
}

int main() {
    scanf ("%d %d", &H, &W);
    FO (i,0,H) {
        FO (p,0,W) {
            scanf (" %c", &gr[i][p]);
            if (gr[i][p] == 'E') {
                exX = p;
                exY =i;
            }
        }
    }
    maxL = (W-exX-1);
    maxR = exX;
    maxU = (H-exY-1);
    maxD = exY;
    FO (i,0,H) {
        FO (p,0,W) {
            if (i == 0) {
                if (p == 0) cum[i][p] = (gr[i][p] == 'o');
                else cum[i][p] = cum[i][p-1] + (gr[i][p] == 'o');
            } else {
                cum[i][p] += cum[i-1][p];
                cum[i][p] += (gr[i][p] == 'o');
                if (p != 0) cum[i][p] += cum[i][p-1] - cum[i-1][p-1];
            }
        }
    }
    FO (i,0,maxL+maxR+maxU+maxD) {
        FO (rig,0,maxR+1) {
            FO (lef,0,maxL+1) {
                FO (dow,0,maxD+1) {
                    int up = i-(rig+lef+dow);
                    if (up < 0 || up > maxU) continue;
                    // Try all directions:
                    int nxt = dp[0][rig][lef][dow];
                    int sL = exX-rig;
                    int sU = exY-dow;
                    int sR = exX+lef;
                    int sD = exY+up;
                    // Left:
                    int tNxt;
                    tNxt = nxt + getInt (sR+1, sU, sR+1, sD, lef, up, W-rig-1, H-dow-1);
                    dp[1][rig][lef+1][dow] = max (dp[1][rig][lef+1][dow], tNxt);
                    // Up:
                    tNxt = nxt + getInt (sL, sD+1, sR, sD+1, lef, up, W-rig-1, H-dow-1);
                    dp[1][rig][lef][dow] = max (dp[1][rig][lef][dow], tNxt);
                    // Right:
                    tNxt = nxt + getInt (sL-1, sU, sL-1, sD, lef, up, W-rig-1, H-dow-1);
                    dp[1][rig+1][lef][dow] = max (dp[1][rig+1][lef][dow], tNxt);
                    // Down:
                    tNxt = nxt + getInt (sL, sU-1, sR, sU-1, lef, up, W-rig-1, H-dow-1);
                    dp[1][rig][lef][dow+1] = max (dp[1][rig][lef][dow+1], tNxt);
                }
            }
        }
        FO (rig,0,maxR+1) {
            FO (lef,0,maxL+1) {
                FO (dow,0,maxD+1) {
                    dp[0][rig][lef][dow] = dp[1][rig][lef][dow];
                    dp[1][rig][lef][dow] = 0;
                }
            }
        }
    }
    printf ("%d\n", dp[0][maxR][maxL][maxD]);
    return 0;
}



Measured memory_bytes: 2816