#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
 
 
ll n;
ll a[200010]={};
ll cnt[200010]={};
vll G[200010];
ll ans[200010]={};
 

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;
    

    ll n;
    ll ans=0;
    string s;
    unordered_map<string,ll> mp;
    cin>>n>>s;
    rep(bit,(1<<n)){
        string u="",t="";
        rep(i,n){
            if(bit&(1<<i)){
                u+=s[i];
            }
            else t+=s[i];
        }
        mp[u+'0'+t]++;
        // cout<<u+'0'+t<<endl;
    }
    rep(bit,(1<<n)){
        string u="",t="";
        rep(i,n){
            if(bit&(1<<i)){
                u=s[i+n]+u;
            }
            else t=s[i+n]+t;
        }
        if(mp[t+'0'+u]>0) ans+=mp[t+'0'+u];
    }
    cout<<ans<<endl;

    
    return 0;
}
#include <cstring>
#include <cctype>
#include <cstdio>
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e2+5;
int max(int a, int b) { return a>b?a:b; }
int min(int a, int b) { return a<b?a:b; }
short f[N][N][N][N], g[N][N], h[N][N];
char s[N][N];
int n, m, ans, px, py;
int main()
{
    n = read(), m = read(); memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; ++i) scanf("%s", s[i]+1);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
        {
            if(s[i][j] == 'E') px = i, py = j;
            g[i][j] = g[i][j-1]+(s[i][j] == 'o');
            h[i][j] = h[i-1][j]+(s[i][j] == 'o'); 
        }    
    f[0][0][0][0] = 0;    
    int pl = py-1, pr = m-py, pd = px-1, pu = n-px, p;
    for(int l = 0; l <= pl; ++l)
        for(int r = 0; r <= pr; ++r)
            for(int d = 0; d <= pd; ++d)
                for(int u = 0; u <= pu; ++u)
                {
                    if(!(~f[l][r][d][u])) continue;
                    int cl = max(r+1, py-l), cr = min(m-l, py+r);
                    int cd = max(u+1, px-d), cu = min(n-d, px+u);
                    if((p = py+r+1) <= m-l) f[l][r+1][d][u] = max(f[l][r+1][d][u], f[l][r][d][u]+h[cu][p]-h[cd-1][p]);
                    if((p = py-l-1) >= r+1) f[l+1][r][d][u] = max(f[l+1][r][d][u], f[l][r][d][u]+h[cu][p]-h[cd-1][p]);
                    if((p = px+u+1) <= n-d) f[l][r][d][u+1] = max(f[l][r][d][u+1], f[l][r][d][u]+g[p][cr]-g[p][cl-1]);
                    if((p = px-d-1) >= u+1) f[l][r][d+1][u] = max(f[l][r][d+1][u], f[l][r][d][u]+g[p][cr]-g[p][cl-1]);                 
                    ans = max(ans, f[l][r][d][u]);
                }
    printf("%d\n", ans);
    return 0;
}