//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

const int INF = 1000000000;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

void dfs(pair<int, int> s, vector<string> &M, vector<vector<int>> &dist, int H, int W) {
    dist[s.first][s.second] = 0;
    queue<pair<int, int>> Q;
    Q.push(s);

    while (!Q.empty()) {
        auto p = Q.front();
        Q.pop();
        int y = p.first;
        int x = p.second;
        int c = dist[y][x];
        for (int i = 0; i < 4; i++) {
            int toY = y + dy[i];
            int toX = x + dx[i];
            if (toY < 0 || toY >= H || toX < 0 || toX >= W) continue;
            if (dist[toY][toX] <= c + 1) continue;
            if (M[toY][toX] == 'x') continue;
            dist[toY][toX] = c + 1;
            Q.push(make_pair(toY, toX));
        }
    }
}

int main() {

    while (true) {

        int W, H;
        cin >> W >> H;

        if (!(W | H)) break;

        vector<string> M(H);
        for (int i = 0; i < H; i++) cin >> M[i];

        int dirty = 0;
        for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (M[i][j] == '*') dirty++;

        auto distP = vector<vector<int>>(H, vector<int>(W, INF));
        auto distG = vector<vector<vector<int>>>(dirty, vector<vector<int>>(H, vector<int>(W, INF)));

        pair<int, int> s;

        vector<pair<int, int>> points;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                auto p = make_pair(i, j);
                if (M[i][j] == 'o') {
                    s = p;
                    dfs(p, M, distP, H, W);
                }
                if (M[i][j] == '*') {
                    points.push_back(p);
                    dfs(p, M, distG[points.size() - 1], H, W);
                }
            }
        }

        vector<int> a(dirty);
        for (int i = 0; i < dirty; i++) a[i] = i;

        long long ans = 10000000000000LL;
        do {

            long long sum = 0;
            sum += distP[points[a[0]].first][points[a[0]].second];

            for (int i = 0; i < dirty - 1; i++) {
                sum += distG[a[i]][points[a[i + 1]].first][points[a[i + 1]].second];
            }

            ans = min(ans, sum);

        } while (next_permutation(a.begin(), a.end()));

        if (ans >= INF) cout << -1 << endl;
        else cout << ans << endl;
    }

}














































Measured memory_bytes: 3276