//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];
	static short row_sum[MAXSIZE][MAXSIZE + 1];
	static short col_sum[MAXSIZE][MAXSIZE + 1];

	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;

	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[r][u][d] = 0;

					if (l >= 1) {
						auto t = dp[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[r][u][d] = MAX(dp[r][u][d], t);
					}
					if (r >= 1) {
						auto t = dp[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[r][u][d] = MAX(dp[r][u][d], t);
					}
					if (u >= 1) {
						auto t = dp[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[r][u][d] = MAX(dp[r][u][d], t);
					}
					if (d >= 1) {
						auto t = dp[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[r][u][d] = MAX(dp[r][u][d], t);
					}
				}
			}
		}
	}

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

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


Measured memory_bytes: 2304