#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    while (1) {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        vector<string> S(h);
        cin >> S;

        vector<pii> dirty;
        int rx, ry;
        REP(i, h) {
            REP(j, w) {
                if (S[i][j] == '*') dirty.push_back({i, j});
                if (S[i][j] == 'o') ry = i, rx = j;
            }
        }
        dirty.push_back({ry, rx});

        int m = SZ(dirty);
        vector<vector<int>> dist(m, vector<int>(m, INF));
        REP(i, m) {
            queue<pii> q;
            q.push(dirty[i]);
            vector<vector<int>> d(h, vector<int>(w, INF));
            d[dirty[i].first][dirty[i].second] = 0;
            while (!q.empty()) {
                int y = q.front().first;
                int x = q.front().second; q.pop();
                REP(dir, 4) {
                    int yy = y + DY[dir];
                    int xx = x + DX[dir];
                    if (INSEG(0, yy, h) && INSEG(0, xx, w) && d[yy][xx] > d[y][x] + 1 && S[yy][xx] != 'x') {
                        d[yy][xx] = d[y][x] + 1;
                        q.push({yy, xx});
                    }
                }
            }
            REP(j, m) {
                int y = dirty[j].first;
                int x = dirty[j].second;
                dist[i][j] = d[y][x];
            }
        }

        m--;
        vector<int> ord(m);
        REP(i, m) ord[i] = i;
        int ans = INF;
        do {
            int tmp = dist[m][ord[0]];
            if (tmp >= INF) continue;
            REP(i, m - 1) {
                tmp += dist[ord[i]][ord[i + 1]];
                if (tmp >= INF) {
                    break;
                }
            }
            chmin(ans, tmp);
        } while (next_permutation(ALL(ord)));
        if (ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return (0^_^0);
}




Measured memory_bytes: 3232