#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX 12
#define mk make_pair
#define INF 1<<28
string s[20];
bool vis[20][20];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int n,w,h,d[MAX][MAX],c;
int dp[1<<MAX][MAX];
int rec(int s,int v){
  if(dp[s][v]>=0)return dp[s][v];
  if(s==(1<<n)-1&&v!=0){return dp[s][v]=0;}
  int res=INF;
  for(int u=0;u<n;u++) 
    if(!(s>>u&1))
      res=min(res,rec(s|1<<u,u)+d[v][u]);
  return dp[s][v]=res;
}
void bfs(int x2,int y2,int k){
  r(i,20)r(j,20)vis[i][j]=0;
  queue<pair<pair<int,int>,int> > q;
  vis[x2][y2]=1;
  q.push(mk(mk(x2,y2),0));
  while(!q.empty()){
    pair<pair<int,int>,int>p=q.front();q.pop();
    int p1=p.first.first,p2=p.first.second,p3=p.second;//cout<<p1<<p2<<p3<<endl;
    r(i,4){
      int x=dx[i]+p1;
      int y=dy[i]+p2;
      if(x>=0&&x<w&&y>=0&&y<h)
        if(!vis[x][y]&&(s[y][x]!='x')){
          if(0<=s[y][x]&&s[y][x]<12)
            d[k][(int)s[y][x]]=p3+1,q.push(mk(mk(x,y),p3+1));
          else if(k!=0&&s[y][x]=='o')
            d[k][0]=p3+1,q.push(mk(mk(x,y),p3+1));
          else q.push(mk(mk(x,y),p3+1));
          vis[x][y]=1;
        }
    }
  }
}
int main(){
  while(cin>>w>>h,w){c=1;
    int a,b;
    vector<pair<int,int> >v;
    r(i,h)cin>>s[i];
    r(j,w)r(i,h)if(s[i][j]=='*')s[i][j]=c++,v.push_back(make_pair(j,i));
  memset(dp,-1,sizeof(dp));
  n=c;
  r(i,MAX)r(j,MAX)d[i][j]=INF;
  r(j,w)r(i,h)if(s[i][j]=='o')a=j,b=i;
  bfs(a,b,0);
  r(i,c-1)bfs(v[i].first,v[i].second,i+1);
  //r(i,c){r(j,c){cout<<d[i][j]<<' ';}cout<<endl;}cout<<d[0][1];
  int p=rec(1,0);
  if(p==INF)p=-1;
  cout<<p<<endl;
  }
}