#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXH 32
#define MAXW 32
#define NUM 16

typedef long long ll;
typedef pair<int, int> point_t; // firstがx,secondがy

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

int w, h;
char field[MAXH][MAXW];
int d[NUM][NUM];

int main(void) {
    while (1) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        point_t point[NUM];
        int cur = 1;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
                if (field[i][j] == '*') {
                    point[cur] = make_pair(j, i);
                    cur++;
                }
                if (field[i][j] == 'o') {
                    point[0] = make_pair(j, i);
                }
            }
        }
        if (cur == 1) {
            cout << 0 << endl;
            continue;
        }
//        cout << "point" << endl;
//        for (int i = 0; i <= cur; i++) cout << point[i].first << " " << point[i].second << endl;
        for (int i = 0; i < cur; i++) {
            for (int j = i+1; j < cur; j++) {
                int dist[MAXH][MAXW];
                bool visited[MAXH][MAXW];
                for (int y = 0; y < h; y++) {
                    for (int x = 0; x < w; x++) {
                        dist[y][x] = INF;
                        visited[y][x] = false;
                    }
                }
                int sx = point[i].first, sy = point[i].second;
                dist[sy][sx] = 0;
                visited[sy][sx] = true;
                queue<point_t> P;
                P.push(make_pair(sx, sy));
                while (!P.empty()) {
                    point_t now = P.front(); P.pop();
                    int x = now.first, y = now.second;
                    for (int k = 0; k < 4; k++) {
                        int nx = x + dx[k];
                        int ny = y + dy[k];
                        if (0 <= nx && nx < w && 0 <= ny && ny < h && visited[ny][nx] == false && field[ny][nx] != 'x') {
                            visited[ny][nx] = true;
                            dist[ny][nx] = dist[y][x] + 1;
                            P.push(make_pair(nx, ny));
                        }
                    }
                }
                d[i][j] = d[j][i] = dist[point[j].second][point[j].first];
            }
        }
//        for (int i = 0; i < cur; i++) d[i][i] = 0;
//        cout << "  ";
//        for (int i = 0; i < cur; i++) cout << i << " ";
//        cout << endl;
//        for (int i = 0; i < cur; i++) {
//            cout << i << " ";
//            for (int j = 0; j < cur; j++) {
//                cout << d[i][j] << " ";
//            }
//            cout << endl;
//        }
        int ans = INF;
        cur--;
        int a[cur];
        for (int i = 0; i < cur; i++) {
            a[i] = i+1;
        }
        do {
            int temp = 0;
            temp += d[0][a[0]];
            for (int i = 1; i < cur; i++) {
                temp += d[a[i-1]][a[i]];
            }
            ans = min(ans, temp);
        } while (next_permutation(a, a+cur));
        if (ans >= INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1220