#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
typedef long long LL;
const int maxn = 105;
const LL mod = 1e9 + 7;

int n, m, x, y;
int f[maxn][maxn][maxn][maxn], r[maxn][maxn], c[maxn][maxn];
char ch;

int main() {
	cin>>n>>m;
	rep(i, 1, n)
	    rep(j, 1, m) {
	    	cin>>ch;
	    	if(ch == 'E') x = i, y = j;
	    	r[i][j] = r[i][j - 1];
	    	c[i][j] = c[i - 1][j];
	    	if(ch == 'o') r[i][j]++, c[i][j]++;
	    }
	int A, B, C, D;
	A = x - 1, B = n - x;
	C = y - 1, D = m - y;
	rep(i, 0, A)
	    rep(j, 0, B)
	        rep(k, 0, C)
	            rep(l, 0, D) {
	            	int val = f[i][j][k][l];
	            	int L = max(y - k, l + 1), R = min(y + l, m - k);
	            	f[i + 1][j][k][l] = max(f[i + 1][j][k][l], val + (r[x - i - 1][R] - r[x - i - 1][L - 1])*(x - i - 1 > j));
	                f[i][j + 1][k][l] = max(f[i][j + 1][k][l], val + (r[x + j + 1][R] - r[x + j + 1][L - 1])*(x + j + 1 + i <= n));
	            	L = max(x - i, j + 1), R = min(x + j, n - i);
	                f[i][j][k + 1][l] = max(f[i][j][k + 1][l], val + (c[R][y - k - 1] - c[L - 1][y - k - 1])*(y - k - 1 > l));
	            	f[i][j][k][l + 1] = max(f[i][j][k][l + 1], val + (c[R][y + l + 1] - c[L - 1][y + l + 1])*(y + l + 1 + k <= m));
	            }
	cout<<f[A][B][C][D]<<endl;
}