#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int X = 105;
char f[X][X];

const int N = X * X;

int dp[N * N / 4];
int sum[X][X];

int _id(int a, int b)
{
    return b * (b + 1) / 2 + a; 
}

int id(int li, int ri, int lj, int rj)
{
    int ans = _id(li, ri) * X * X / 2 + _id(lj, rj);

    //eprintf("id(%d, %d, %d, %d) = %d\n", li, ri, lj, rj, ans);
    return ans;
}

void upd(int &a, int b)
{
//    eprintf("upd with %d\n", b);
    a = max(a, b);
}

int getSum(int li, int ri, int lj, int rj)
{
    if (li > ri || lj > rj)
        return 0;
    int ans = sum[ri + 1][rj + 1] - sum[li][rj + 1] - sum[ri + 1][lj] + sum[li][lj]; 
    //eprintf("sum [%d, %d] x [%d, %d] = %d\n", li, ri, lj, rj, ans);
    return ans;
}

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", f[i]);

    int ei, ej;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            if (f[i][j] == 'E')
            {
                ei = i;
                ej = j;
            }
            sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + (f[i][j] == 'o');
        }

    int ans = 0;

    for (int li = 0; li < n; li++)
        for (int ri = n - 1; ri >= li; ri--)
            for (int lj = 0; lj < m; lj++)
                for (int rj = m - 1; rj >= lj; rj--)
                {
                    int cur = dp[id(li, ri, lj, rj)];
      //              eprintf("[%d, %d] x [%d, %d] : %d\n", li, ri, lj, rj, cur);
                    upd(ans, cur);

                    if (li == ri && lj == rj && f[li][lj] == 'o')
                        upd(ans, cur + 1);
                        
                    if (li < ri)
                    {
                        {
                            int nx = cur;
                            if (ri + (ei - li) < n)
                                nx += getSum(li, li, max(lj, ej - (m - 1 - rj)), min(rj, ej + lj));
                            upd(dp[id(li + 1, ri, lj, rj)], nx);
                        }
                        {
                            int nx = cur;
                            if (li - (ri - ei) >= 0)
                                nx += getSum(ri, ri, max(lj, ej - (m - 1 - rj)), min(rj, ej + lj));
                            upd(dp[id(li, ri - 1, lj, rj)], nx);
                        }
                    }
                    if (lj < rj)
                    {
                        {
                            int nx = cur;
                            if (rj + (ej - lj) < m)
                                nx += getSum(max(li, ei - (n - 1 - ri)), min(ri, ei + li), lj, lj);
                            upd(dp[id(li, ri, lj + 1, rj)], nx);
                        }
                        {
                            int nx = cur;
                            if (lj - (rj - ej) >= 0)
                                nx += getSum(max(li, ei - (n - 1 - ri)), min(ri, ei + li), rj, rj);
                            upd(dp[id(li, ri, lj, rj - 1)], nx);
                        }
                    }

                }

    printf("%d\n", ans);
	return 0;
}




Measured memory_bytes: 110848