#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
#include <unordered_set>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
//ll min(int a, ll b) {return a < b ? a : b;}
//ll min(ll a, int b) {return a < b ? a : b;}
//ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
//ll max(int a, ll b) {return a > b ? a : b;}
//ll max(ll a, int b) {return a > b ? a : b;}
//ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

int n, m;
string s[102];
int ver[101][101];
int hor[101][101];

short dp[101][101][101][101];
short ans;

int summ_hor(int x, int y)
{
    if (y < 0) return 0;
    return hor[x][y];
}

int summ_ver(int x, int y)
{
    if (x < 0) return 0;
    return ver[x][y];
}

int getD(int id, int l, int r, int blocked)
{
    if (l > r) return 0;
    if (id <= blocked) return summ_hor(id, r) - summ_hor(id, l - 1);
    return 0;
}

int getU(int id, int l, int r, int blocked)
{
    if (l > r) return 0;
    if (blocked <= id) return summ_hor(id, r) - summ_hor(id, l - 1);
    return 0;
}

int getR(int id, int l, int r, int blocked)
{
    if (l > r) return 0;
    if (id <= blocked) return summ_ver(r, id) - summ_ver(l - 1, id);
    return 0;
}

int getL(int id, int l, int r, int blocked)
{
    if (l > r) return 0;
    if (blocked <= id) return summ_ver(r, id) - summ_ver(l - 1, id);
    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    int x, y;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            hor[i][j] = summ_hor(i, j - 1) + (s[i][j] == 'o');
            ver[i][j] = summ_ver(i - 1, j) + (s[i][j] == 'o');
            if (s[i][j] == 'E') x = i, y = j;
        }
    }
    for (int d = 0; x + d + 1 <= n; d++)
    {
        for (int u = 0; x - u - 1 >= -1; u++)
        {
            for (int r = 0; y + r + 1 <= m; r++)
            {
                for (int l = 0; y - l - 1 >= -1; l++)
                {
                    if (x + d + 1 < n) dp[d + 1][u][r][l] = max(dp[d + 1][u][r][l], dp[d][u][r][l] + getD(x + d + 1, max(r, y - l), min(m - l - 1, y + r), n - u - 1));
                    if (x - u - 1 >= 0) dp[d][u + 1][r][l] = max(dp[d][u + 1][r][l], dp[d][u][r][l] + getU(x - u - 1, max(r, y - l), min(m - l - 1, y + r), d));
                    if (y + r + 1 < m) dp[d][u][r + 1][l] = max(dp[d][u][r + 1][l], dp[d][u][r][l] + getR(y + r + 1, max(d, x - u), min(n - u - 1, x + d), m - l - 1));
                    if (y - l - 1 >= 0) dp[d][u][r][l + 1] = max(dp[d][u][r][l + 1], dp[d][u][r][l] + getL(y - l - 1, max(d, x - u), min(n - u - 1, x + d), r));
                }
            }
        }
    }
    for (int d = 0; x + d + 1 <= n; d++)
        for (int u = 0; x - u - 1 >= -1; u++)
            for (int r = 0; y + r + 1 <= m; r++)
                for (int l = 0; y - l - 1 >= -1; l++)
                    ans = max(ans, dp[d][u][r][l]);
    cout << ans;
}


Measured memory_bytes: 199040