#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1e9

bool isin(int i, int j, int h, int w){
    return i>=0 && j>=0 && i<h && j<w;
}

int main() {
    int w, h;

    while (cin >> w >> h && w) {
        VVI f(h,VI(w));
        vector<P> p(1);
        REP(i,h) {
            string s;
            cin >> s;
            REP(j,w) {
                if (s[j] == 'o') p[0] = make_pair(i, j);
                if (s[j] == '*') p.push_back(make_pair(i, j));
                if (s[j] == 'x') f[i][j] = 1;
            }
        }
        int n = p.size();
        VVI dist(n, VI(n));
        REP(x,n){
            VVI d(h,VI(w));
            queue<P> que;
            d[p[x].first][p[x].second] = 1;
            que.push(make_pair(p[x].first, p[x].second));
            int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};
            while (!que.empty()){
                P po = que.front();
                que.pop();
                int i = po.first, j = po.second;
                REP(k,4){
                    int ii = i+dx[k], jj = j+dy[k];
                    if (!isin(ii,jj,h,w) || d[ii][jj] > 0 || f[ii][jj]) continue;
                    d[ii][jj] = d[i][j] + 1;
                    que.push(make_pair(ii, jj));
                }
            }
            REP(y,n){
                dist[x][y] = d[p[y].first][p[y].second] - 1;
            }
        }
        bool flag = 0;
        REP(i,n) REP(j,n) {
            if (dist[i][j] == -1){
                flag = 1;
            }
        }
        if (flag) {
            cout << -1 << endl;
            continue;
        }

        VVI dp(1<<n, VI(n, INF));
        dp[1][0] = 0;
        REP(i,1<<n) REP(j,n) REP(k,n) {
            if ((i>>k) & 1) continue;
            dp[i | (1<<k)][k] = min(dp[i | (1<<k)][k], dp[i][j] + dist[j][k]);
        }

        int ans = 1e9;
        REP(j,n) ans = min(ans, dp[(1<<n)-1][j]);
        cout << ans << endl;

    }

    return 0;
}