import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable int INF = 1 << 28;
int[] dr = [0, 0, -1, 1]; 
int[] dc = [-1, 1, 0, 0];

void main() {
    while (true) {
        auto s = readln.split.map!(to!int);
        auto W = s[0];
        auto H = s[1];
        if (W == 0) break;
        auto B = H.iota.map!(_ => readln.chomp).array;

        int start;
        int[] dests;
        int[][] dist = new int[][](H*W, H*W);
        foreach (i; 0..H*W)
            foreach(j; 0..H*W)
                dist[i][j] = i == j ? 0 : INF;

        foreach (i; 0..H) {
            foreach (j; 0..W) {
                if (B[i][j] == 'o') start = i * W + j;
                if (B[i][j] == '*') dests ~= i * W + j;
                if (B[i][j] == 'x') continue;
                foreach (k; 0..4) {
                    int ni = i + dr[k];
                    int nj = j + dc[k];
                    if (ni < 0 || ni >= H || nj < 0 || nj >= W)
                        continue;
                    if (B[ni][nj] == 'x')
                        continue;
                    dist[i * W + j][ni * W + nj] = 1;
                }
            }
        }

        foreach (i; 0..H*W)
            foreach (j; 0..H*W)
                foreach (k; 0..H*W)
                    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);

        if (dests.map!(d => dist[start][d] == INF).any) {
            writeln(-1);
            break;
        }
        
        int M = dests.length;
        auto mem = new int[][](1 << M, M + 1);
        foreach (i; 0..(1 << M)) fill(mem[i], -1);
        
        int dp(int mask, int from) {
            if (mask == 0) return dist[start][dests[from]];
            if (mem[mask][from] >= 0) return mem[mask][dests[from]];

            int ret = INF;
            foreach (i; 0..M) {
                if (mask & (1 << i)) {
                    int tmp = from < M ? dist[dests[from]][dests[i]] : 0;
                    tmp += dp(mask - (1 << i), i);
                    ret = min(ret, tmp);
                }
            }

            return mem[mask][from] = ret;
        }

        int ans = dp((1 << M) - 1, M);
        writeln(ans == INF ? -1 : ans);
    }
}