#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll h,w;
namespace solve{
  #define H 20
  ll mas[H][H];
  ll px[H],py[H];
  ll d[H][H];
  
  struct qry{
      ll x,y,cost;
  };queue<qry> Q;
  void push(ll x,ll y,ll cost){
    qry gen;gen.x=x,gen.y=y,gen.cost=cost;
    Q.push(gen);
  }
  void dist(ll s){
    for(int i=0;i<H;i++)d[s][i]=1e9;
    ll dis[H][H];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)dis[i][j]=1e9;
    push(px[s],py[s],0);
    while(!Q.empty()){
      qry gen=Q.front(); Q.pop();
      ll x=gen.x,y=gen.y,cost=gen.cost;
      if(mas[x][y]==-2)continue;
      if(dis[x][y]<=cost)continue;
      dis[x][y]=cost;
      if(mas[x][y]>0)d[s][mas[x][y]]=cost;
      ll dx[]={0,1,0,-1},dy[]={1,0,-1,0};
      for(int r=0;r<4;r++){
	ll xx=x+dx[r],yy=y+dy[r];
	if(0<=xx&&xx<h&&0<=yy&&yy<w){
	  push(xx,yy,cost+1);
	}
      }
    }
  }
  void main(){
    ll cnt=1;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
      char c;cin>>c;
      if(c=='o')mas[i][j]=0,px[0]=i,py[0]=j;
      if(c=='*')mas[i][j]=cnt,px[cnt]=i,py[cnt]=j,cnt++;
      if(c=='x')mas[i][j]=-2;
      if(c=='.')mas[i][j]=-1;
    }
    for(int i=0;i<cnt;i++)dist(i);
    /*
    for(int i=0;i<cnt;i++){
      cout<<i<<":";
      for(int j=1;j<cnt;j++)cout<<d[i][j]<<" ";cout<<endl;
    }
    for(int i=0;i<cnt;i++)cout<<i<<"@"<<px[i]<<" "<<py[i]<<endl;*/
    vector<ll> v; for(int i=1;i<cnt;i++)v.push_back(i);
    ll ans=1e9;
    do{
      ll cur=d[0][v[0]];
      for(int i=1;i<cnt-1;i++)cur+=d[v[i-1]][v[i]];
      ans=min(ans,cur);
    }while(next_permutation(v.begin(),v.end()));
    if(ans>1e5)ans=-1;
    cout<<ans<<endl;
  }
};
int main(){
  while(cin>>w>>h&&h>0&&w>0){
    solve::main();
  }
    return 0;
}

