#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

struct Info {
    int i, j, idx;
    Info(int a, int b, int c) : i(a), j(b), idx(c) {}
};

bool operator<(const Info &a, const Info &b) { return a.idx < b.idx; }

int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};

int d[20][30][30];
int used[20][30][30];

const int INF = 1e5;

int main() {
    int w, h;
    while (cin >> w >> h) {
        if (w + h == 0) break;
        string mp[h];
        int sy, sx;
        vector<Info> dust;
        for (int i = 0; i < h; i++) cin >> mp[i];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (mp[i][j] == 'o') {
                    sy = i;
                    sx = j;
                } else if (mp[i][j] == '*') {
                    dust.push_back(Info(i, j, dust.size() + 1));
                }
            }
        }
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 30; j++) {
                for (int k = 0; k < 30; k++) {
                    d[i][j][k] = INF;
                    used[i][j][k] = 0;
                }
            }
        }
        queue<pii> q;
        q.push(pii(sy, sx));
        d[0][sy][sx] = 0;
        used[0][sy][sx] = 1;
        while (!q.empty()) {
            int ci = q.front().first;
            int cj = q.front().second;
            q.pop();
            for (int k = 0; k < 4; k++) {
                int ni = ci + di[k];
                int nj = cj + dj[k];
                if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
                if (mp[ni][nj] == 'x') continue;
                if (used[0][ni][nj] == 0 && d[0][ni][nj] > d[0][ci][cj] + 1) {
                    d[0][ni][nj] = d[0][ci][cj] + 1;
                    used[0][ni][nj] = 1;
                    q.push(pii(ni, nj));
                }
            }
        }
        for (int i = 0; i < dust.size(); i++) {
            queue<pii> q;
            int idx = dust[i].idx;
            q.push(pii(dust[i].i, dust[i].j));
            d[idx][dust[i].i][dust[i].j] = 0;
            used[idx][dust[i].i][dust[i].j] = 1;
            while (!q.empty()) {
                int ci = q.front().first;
                int cj = q.front().second;
                q.pop();
                for (int k = 0; k < 4; k++) {
                    int ni = ci + di[k];
                    int nj = cj + dj[k];
                    if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
                    if (mp[ni][nj] == 'x') continue;
                    if (used[idx][ni][nj] == 0 &&
                        d[idx][ni][nj] > d[idx][ci][cj] + 1) {
                        d[idx][ni][nj] = d[idx][ci][cj] + 1;
                        used[idx][ni][nj] = 1;
                        q.push(pii(ni, nj));
                    }
                }
            }
        }
        int ans = INF;
        do {
            int tmp = 0, p = 0;
            for (int i = 0; i < dust.size(); i++) {
                tmp += d[p][dust[i].i][dust[i].j];
                p = dust[i].idx;
            }
            ans = min(ans, tmp);
        } while (next_permutation(dust.begin(), dust.end()));
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}


Measured memory_bytes: 3332