#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i ++)

struct state {
        int y;
        int x;
        int step;
};

static const int dx[] = { 1, -1, 0, 0 }, dy[] = { 0, 0, 1, -1 };
static const int INF = 0x3f3f3f3f;

void dfs(int s, vector<vector<int>>& g, int cnt, int cost, int& ans, int V, vector<int>& used_dfs) {
        if (cnt == V) {
                ans = min(ans, cost);
                return;
        }
        used_dfs[s] = true;
        for (int v = 0; v < V; v ++) {
                if (g[s][v] != INF && !used_dfs[v]) {
                        cost += g[s][v];
                        dfs(v, g, cnt + 1, cost, ans, V, used_dfs);
                        cost -= g[s][v];

                }
        }
        used_dfs[s] = false;
        return;
}

int main() {
        int w, h;
        while (cin >> w >> h && w) {
                vector<string> room(h);
                rep(i, h) cin >> room[i];
                int V = 0;
                int sx, sy;
                vector<pair<int, int>> node;
                rep(y, h) {
                        rep(x, w) {
                                if (room[y][x] == 'o') {
                                        V ++;
                                        sy = y;
                                        sx = x;
                                }
                                if (room[y][x] == '*') {
                                        V ++;
                                        node.emplace_back(y, x);
                                }
                        }
                }
                node.emplace_back(sy, sx);
                reverse(node.begin(), node.end()); //node[0]??????????????????node[1] ~ node[V - 1]????±?????????¨?±?
                vector<vector<int>> g(V, vector<int> (V, INF));
                bool cantgo = false;
                for (int i = 0; i < V; i ++) {
                        for (int j = i + 1; j < V; j ++) {
                                int cost = 0;
                                int starty = node[i].first;
                                int startx = node[i].second;
                                int goaly = node[j].first;
                                int goalx = node[j].second;
                                queue<state> q;
                                vector<vector<bool>> used(h, vector<bool> (w, false));
                                q.push({starty, startx, 0});
                                used[starty][startx] = true;
                                while (!q.empty()) {
                                        state now = q.front(); q.pop();
                                        if (now.y == goaly && now.x == goalx) {
                                                cost = now.step;
                                                break;
                                        }
                                        for (int d = 0; d < 4; d ++) {
                                                state next;
                                                next.y = now.y + dy[d];
                                                next.x = now.x + dx[d];
                                                if (h <= next.y || next.y < 0 || w <= next.x || next.x < 0 ||
                                                    used[next.y][next.x] || room[next.y][next.x] == 'x') {
                                                        continue;
                                                }
                                                used[next.y][next.x] = true;
                                                next.step = now.step + 1;
                                                q.push(next);
                                        }
                                }
                                if (cost == 0) cantgo = true;
                                g[i][j] = cost;
                                g[j][i] = cost;
                        }
                }
                if (cantgo) {
                        cout << -1 << endl;
                        continue;
                }
                int ans = INF;
                vector<int> used_dfs(V, 0);
                dfs(0, g, 1, 0, ans, V, used_dfs);
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 3024