//ProblemC.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

#define MAXSIZE 100

using namespace std;

//ProblemC.cpp

#if OJ_MYPC
#include <fstream>
#endif

int main(int argc, char* argv[])
{
	OPENOJIO;

	int h, w;
	short robot[MAXSIZE][MAXSIZE];
	static short dp[MAXSIZE][MAXSIZE][MAXSIZE][MAXSIZE];
	static short row_sum[MAXSIZE][MAXSIZE + 1];
	static short col_sum[MAXSIZE][MAXSIZE + 1];

#if OJ_MYPC
	ofstream ofs("text.txt");
	static char route[MAXSIZE][MAXSIZE][MAXSIZE][MAXSIZE];
#endif

	ip >> h >> w;
	char c;
	int ie, je;
	for(int i = 0;i < h; ++i)
		for (int j = 0; j < w; ++j)
		{
			ip >> c;
			if (c == 'E') { ie = i; je = j; }
			robot[i][j] = c == 'o';
		}

	for (int i = 0; i < h; ++i) {
		row_sum[i][0] = 0;
		for (int j = 1; j <= w; ++j)
			row_sum[i][j] = row_sum[i][j - 1] + robot[i][j - 1];
	}

	for (int j = 0; j < w; ++j) {
		col_sum[j][0] = 0;
		for (int i = 1; i <= h; ++i)
			col_sum[j][i] = col_sum[j][i - 1] + robot[i - 1][j];
	}

	int lm = je;
	int rm = w - je - 1;
	int um = ie;
	int dm = h - ie - 1;

	FillZero(dp);
	dp[0][0][0][0] = 0;

	for (int l = 0; l <= lm; ++l) {
		for (int r = 0; r <= rm; ++r) {
			for (int u = 0; u <= um; ++u) {
				for (int d = 0; d <= dm; ++d) {
					dp[l][r][u][d] = 0;

					if (l >= 1) {
						auto t = dp[l - 1][r][u][d];
						auto st = MAX(ie - u, d);
						auto ed = MIN(ie + d + 1, h - u);
						if (je - l >= r && ed > st) {
							t += col_sum[je - l][ed] - col_sum[je - l][st];
						}

						dp[l][r][u][d] = MAX(dp[l][r][u][d], t);

#if OJ_MYPC
							if (dp[l][r][u][d] == t) route[l][r][u][d] = 'L';
#endif
					}
					if (r >= 1 ) {
						auto t = dp[l][r - 1][u][d];
						auto st = MAX(ie - u, d);
						auto ed = MIN(ie + d + 1, h - u);
						if (je + r < w - l && ed > st)
							t += col_sum[je + r][ed] - col_sum[je + r][st];

						dp[l][r][u][d] = MAX(dp[l][r][u][d], t);

#if OJ_MYPC
							if (dp[l][r][u][d] == t) route[l][r][u][d] = 'R';
#endif
					}
					if (u >= 1) {
						auto t = dp[l][r][u - 1][d];
						auto st = MAX(je - l, r);
						auto ed = MIN(je + r + 1, w - l);
						if (ed >= st && ie - u >= d)
							t += row_sum[ie - u][ed] - row_sum[ie - u][st];

						dp[l][r][u][d] = MAX(dp[l][r][u][d], t);

#if OJ_MYPC
							if (dp[l][r][u][d] == t) route[l][r][u][d] = 'U';
#endif
					}
					if (d >= 1) {
						auto t = dp[l][r][u][d - 1];
						auto st = MAX(je - l, r);
						auto ed = MIN(je + r + 1, w - l);
						if (ed >= st && ie + d < h - u)
							t += row_sum[ie + d][ed] - row_sum[ie + d][st];

						dp[l][r][u][d] = MAX(dp[l][r][u][d], t);

#if OJ_MYPC
							if (dp[l][r][u][d] == t) route[l][r][u][d] = 'D';
#endif
					}

					
				}
			}
		}
	}

	int rst = dp[lm][rm][um][dm];
	op << rst << endl;

#if OJ_MYPC
	int l = lm;
	int r = rm;
	int u = um;
	int d = dm;
	while (l != 0 || r != 0 || u != 0 || d != 0)
	{
		char t = route[l][r][u][d];

		ofs << l << ' ' << r << ' ' << u << ' ' << d << endl;
		ofs << t << endl << dp[l][r][u][d] << endl << endl;

		
		switch (t)
		{
		case 'L':
			--l;
			break;
		case 'R':
			--r;
			break;
		case 'D':
			--d;
			break;
		case 'U':
			--u;
			break;
		default:
			throw "None!";
		}
		if (l < 0 || r < 0 || u < 0 || d < 0)
			throw "Minus!";
	}
	ofs.close();
#endif

	return 0;
}
/***************************************************************/


Measured memory_bytes: 195712