#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int h, w; cin >> w >> h;
    if(h == 0 && w == 0) break;
    vector<vector<bool>> grid(h, vector<bool>(w, false));
    P st = {-1, -1};
    vector<P> dist;
    for(int i=0;i<h;++i) {
      for(int j=0;j<w;++j) {
        char tmp; cin >> tmp;
        if(tmp == 'o') {
          st = {i, j};
          dist.emplace_back(st);
        } else if(tmp == '*') {
          dist.emplace_back(make_pair(i, j));
        } else if(tmp == 'x') {
          grid[i][j] = true;
        }
      }
    }
    sort(dist.begin(), dist.end());
    int n = (int)(dist.size());
    vvi d(n, vi(n, INF));
    for(int i=0;i<n;++i) {
      vector<vector<bool>> sel(h, vector<bool>(w, false));
      queue<pair<int, P>> que;
      d[i][i] = 0;
      sel[dist[i].first][dist[i].second] = true;
      que.push({0, dist[i]});
      while(!que.empty()) {
        pair<int, P> now = que.front(); que.pop();
        for(int j=0;j<4;++j) {
          int nx = now.second.first + dx[j], ny = now.second.second + dy[j];
          if(!(0 <= nx && nx < h && 0 <= ny && ny < w)) continue;
          if(sel[nx][ny] || grid[nx][ny]) continue;
          sel[nx][ny] = true;
          auto it = lower_bound(dist.begin(), dist.end(), make_pair(nx, ny));
          if(it != dist.end() && (*it).first == nx && (*it).second == ny) {
            int pos = distance(dist.begin(), it);
            d[i][pos] = now.first + 1;
          }
          que.push({now.first + 1, {nx, ny}});
        }
      }
    }
    bool ok = true;
    for(int i=0;i<n;++i) {
      for(int j=0;j<n;++j) {
        if(d[i][j] == INF) {
          ok = false;
          break;
        }
      }
      if(!ok) break;
    }
    if(!ok) {
      cout << -1 << endl;
      continue;
    }
    int sz = 1;
    for(int i=0;i<n;++i) {
      sz *= 2;
    }
    vvi dp(n, vi(sz, INF));
    auto it = lower_bound(dist.begin(), dist.end(), st);
    int init = distance(dist.begin(), it);
    dp[init][1<<(init)] = 0;
    priority_queue<pair<int, P>> pq;
    pq.push({0, {init, 1<<(init)}});
    while(!pq.empty()) {
      pair<int, P> now = pq.top(); pq.pop();
      int l = now.first, idx = now.second.first, bs = now.second.second;
      if(dp[idx][bs] < l) continue;
      for(int i=0;i<n;++i) {
        if((bs | (1<<i)) != bs && dp[i][bs|(1<<i)] > l + d[idx][i]) {
          dp[i][bs|(1<<i)] = l + d[idx][i];
          pq.push({dp[i][bs|(1<<i)], {i, bs|(1<<i)}});
        }
      }
    }
    int mi = INF;
    for(int i=0;i<n;++i) {
      if(i == init) continue;
      mi = min(mi, dp[i][sz-1]);
    }
    cout << mi << endl;
  }
}



Measured memory_bytes: 3136