function BFS(X,Y){
   var dx=[0,-1,1,0];
   var dy=[-1,0,0,1];
   var cnt=0;
   var bfs=[[X,Y,cnt,0,YX]];
   var obj={};
   obj[X+" "+Y+" "+0+" "+YX.join("")]=true;
   while(true){
      if(bfs.length==0){cnt=-1;break;}
      var leaf=bfs.shift();
      var x=leaf[0];
      var y=leaf[1];
      var c=leaf[2];
      var d=leaf[3];
      if(d==dust){cnt=c;break;}
      var yx=leaf[4];
      for(var i=0;i<4;i++){
         var xx=x+dx[i];
         var yy=y+dy[i];
         var dd=d;
         if(xx<0 || yy<0 || xx>=wh[0] || yy>=wh[1])continue;
         if(yx[yy][xx]=="x")continue;
         if(obj.hasOwnProperty(xx+" "+yy+" "+d+" "+yx.join("")))continue;
         obj[xx+" "+yy+" "+d+" "+yx.join("")]=true;
         var copy=yx.map(function(v){return v.slice();});
         if(copy[yy][xx]=="*"){
            copy[yy][xx]=".";
            dd++;
         }
         bfs.push([xx,yy,c+1,dd,copy]);
      }
   }
   return cnt;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var wh=Arr.shift().split(" ").map(Number);
   if(wh[0]==0 && wh[1]==0)break;
   var YX=[];
   var start=[];
   var dust=0;
   for(var i=0;i<wh[1];i++){
      var arr=(Arr.shift()).split("");
      if(arr.indexOf("o")!=-1)start=[arr.indexOf("o"),i];
      arr.forEach(function(v){if(v=="*")dust++;});
      YX.push(arr);
   }
   var ans=BFS(start[0],start[1]);
   console.log(ans);
}