#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=110;
int dp[N][N];int ans;
int s1[2][N][N],s2[N][N];int a[N][N];char s[N];
int px,py;int n,m;

void init(){
	int i,j;
	rep(i,1,n)	rep(j,1,m)	s1[0][i][j]=s1[0][i][j-1]+a[i][j];
	rep(i,1,n)	rep(j,1,m)	s1[1][i][j]=s1[1][i-1][j]+a[i][j];
	rep(i,1,n)	rep(j,1,m)	s2[i][j]=s2[i-1][j]+s1[0][i][j];
}

void calc(int x,int y){
	int i,j,tx,ty,lx,ly;
	memset(dp,0,sizeof(dp));
	tx=px+x-(n-px);ty=py+y-(m-py);
	dp[tx][ty]=s2[px+x][py+y]-s2[px+x][ty-1]-s2[tx-1][py+y]+s2[tx-1][ty-1];
	lx=n-px;ly=m-py;
	for(i=tx;i>=x+1;i--){
		for(j=ty;j>=y+1;j--){
			if(i<tx)	dp[i][j]=max(dp[i][j],dp[i+1][j]+s1[0][i][j+ly]-s1[0][i][j-1]);
			if(j<ty)	dp[i][j]=max(dp[i][j],dp[i][j+1]+s1[1][i+lx][j]-s1[1][i-1][j]);
			//if(x==1&&y==0)	cerr<<i<<' '<<j<<' '<<dp[i][j]<<endl;
		}
	}
	//cerr<<x<<' '<<y<<' '<<dp[x+1][y+1]<<endl;
	ans=max(ans,dp[x+1][y+1]);
}

void work(){
	int i,j;
	rep(i,0,px-1)	rep(j,0,py-1){
		if(px+i>n||py+j>m)	continue;
		calc(i,j);
	}
}
			

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,j;
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			if(s[j]=='.')	a[i][j]=0;
			else if(s[j]=='o')	a[i][j]=1;
			else px=i,py=j;
		}
	}
	if(px-1<n-px){
		rep(i,1,n)	rep(j,1,m)	if(i<n-i+1)	swap(a[i][j],a[n-i+1][j]);
		px=n-px+1;
	}
	if(py-1<m-py){
		rep(i,1,n)	rep(j,1,m)	if(j<m-j+1)	swap(a[i][j],a[i][m-j+1]);
		py=m-py+1;
	}
	/*cerr<<px<<' '<<py<<endl;
	rep(i,1,n){
		rep(j,1,m)	cerr<<a[i][j];
		cerr<<endl;
	}*/
	init();work();
	printf("%d\n",ans);
}

































































































