#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1020000000

int solve(int w, int h){
  vector<string> vec(h);
  rep(i,h) cin>>vec[i];

  int n = w*h;
  vector<vector<int>> d(n,vector<int>(n, INF));
  rep(i,n) d[i][i] = 0;
  rep(i,h)rep(j,w) if(vec[i][j]!='x'){
    if(j+1<w && vec[i][j+1]!='x') d[i*w+j][i*w+j+1] = d[i*w+j+1][i*w+j] = 1;
    if(i+1<h && vec[i+1][j]!='x') d[i*w+j][(i+1)*w+j] = d[(i+1)*w+j][i*w+j] = 1;
  }

  rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][k]+d[k][j], d[i][j]);

  int m = 0;
  vector<int> pos;
  rep(i,h)rep(j,w) if(vec[i][j] == '*'){pos.pb(i*w+j); m++;}

  int s;
  rep(i,h)rep(j,w) if(vec[i][j] == 'o') s = i*w+j;

  vector<vector<int>> dp(1<<m, vector<int>(m, INF));
  rep(i,m) dp[1<<i][i] = d[s][pos[i]];
  rep(mask,1<<m) rep(i,m) if(dp[mask][i]<INF){
    rep(j,m) if( !(mask & (1<<j) ) ){
      dp[mask | (1<<j)][j] = min(dp[mask | (1<<j)][j], dp[mask][i] + d[pos[i]][pos[j]]);
    }
  }

  int ans = *min_element(all(dp[(1<<m)-1]));
  if(ans == INF) return -1;
  return ans;
}

int main(){
  int w,h;
  while(cin>>w>>h, w|h){
    cout << solve(w,h) << endl;
  }

  return 0;
}