#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef __int128_t lll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
int rd(int s, int e) { return rand()%(e-s+1) + s; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXH = 102;
const int MAXW = 102;

unordered_map<int, int> MP[MAXH+MAXW];

int S[MAXH][MAXW];
char A[MAXH][MAXW];

int H, W, Y, X;
int Ans;

int hsh(int l, int r, int u, int d) {
	return ((l * 101 + r) * 101 + u) * 101 + d;
}
void rhs(int key, int &l, int &r, int &u, int &d) {
	d = key % 101; key /= 101;
	u = key % 101; key /= 101;
	r = key % 101;
	l = key / 101;
}

int f(int sy, int sx, int ey, int ex) {
	sy--; sx--;
	return S[ey][ex] - S[ey][sx] + S[sy][sx] - S[sy][ex];
}

int main() {
	scanf("%d%d", &H, &W);
	for(int i = 1; i <= H; i++) scanf(" %s", A[i]+1);

	for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++) {
		if('E' == A[i][j]) {
			Y = i; X = j;
		} else if('o' == A[i][j]) {
			S[i][j]++;
		}
		S[i][j] += S[i-1][j] - S[i-1][j-1] + S[i][j-1];
	}

	MP[0][hsh(0, 0, 0, 0)] = 0;

	for(int sum = 0; sum <= H+W; sum++) {
		for(auto &it : MP[sum]) {
			int l, r, u, d, c = it.second;
			rhs(it.first, l, r, u, d);
			upmax(Ans, c);

			if(X+l+1 <= W-r)
				upmax(MP[sum+1][hsh(l+1, r, u, d)], c + f(max(Y-d, u+1), X+l+1, min(Y+u, H-d), X+l+1));
			if(l+1 <= X-r-1)
				upmax(MP[sum+1][hsh(l, r+1, u, d)], c + f(max(Y-d, u+1), X-r-1, min(Y+u, H-d), X-r-1));
			if(Y+u+1 <= H-d)
				upmax(MP[sum+1][hsh(l, r, u+1, d)], c + f(Y+u+1, max(l+1, X-r), Y+u+1, min(X+l, W-r)));
			if(u+1 <= Y-d-1)
				upmax(MP[sum+1][hsh(l, r, u, d+1)], c + f(Y-d-1, max(l+1, X-r), Y-d-1, min(X+l, W-r)));
		}
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 113420