#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int TravelingSalesman(const Graph &g) {
const int n = g.size(), INF = n * n * n;
vector<vector<int>> dp(1 << n, vector<int>(n, INF));
dp[1][0] = 0;
for (int s = 1; s < 1 << n; ++s) {
for (int cur = 0; cur < n; ++cur) {
if (!(s >> cur & 1) || INF <= dp[s][cur]) continue;
for (int dst = 0; dst < n; ++dst) {
if (dst != cur && !(s >> dst & 1))
dp[s | 1 << dst][dst] = min(dp[s | 1 << dst][dst], dp[s][cur] + g[cur][dst]);
}
}
}
return *min_element(dp[(1 << n) - 1].begin(), dp[(1 << n) - 1].end());
}
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, -1, 0, 1};
int Distance(const auto &src, const auto &dst, const int h, const int w, const vector<string> &c) {
vector<vector<int>> d(h, vector<int>(w, -1));
queue<pair<int, int>> que;
que.push(src);
d[src.first][src.second] = 0;
while (!que.empty()) {
auto cur = que.front(); que.pop();
for (int dir = 0; dir < 4; ++dir) {
pair<int, int> nxt(cur.first + dr[dir], cur.second + dc[dir]);
if (nxt.first < 0 || nxt.second < 0 || h <= nxt.first || w <= nxt.second
|| d[nxt.first][nxt.second] != -1 || c[nxt.first][nxt.second] == 'x')
continue;
d[nxt.first][nxt.second] = d[cur.first][cur.second] + 1;
que.push(nxt);
}
}
return d[dst.first][dst.second];
}
pair<bool, Graph> MakeGraph(const int w, const int h, const vector<string> &c) {
vector<pair<int, int>> pos(1);
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j) {
if (c[i][j] == 'o') pos[0] = make_pair(i, j);
else if (c[i][j] == '*') pos.emplace_back(make_pair(i, j));
}
const int n = pos.size();
Graph d(n, vector<int>(n));
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j) {
int d_ij = Distance(pos[i], pos[j], h, w, c);
if (d_ij == -1) return make_pair(true, d);
d[i][j] = d[j][i] = d_ij;
}
return make_pair(false, d);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int w, h;
while (cin >> w >> h, (w != 0 || h != 0)) {
vector<string> c(h);
for (auto &x : c) cin >> x;
auto res = MakeGraph(w, h, c);
if (res.first) cout << -1 << '\n';
else cout << TravelingSalesman(res.second) << '\n';
}
return 0;
}