#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <utility>
#include <cassert>
using namespace std;

int n;
int h,w;
int g[444][444];
char grid[30][30];
vector<pair<int,int> > gar;
vector<vector<pair<int,int> > > adj; // dst, weight

const int inf = 1e9;

int getId(int i, int j){
    return i*w + j;
}

int dp[12][1<<12];
int rec(int visSet, int v){
    int res = dp[v][visSet];
    if(res != -1) return res;
    visSet |= 1<<v;
    if(visSet+1 == 1<<n) return res = 0;
    // printf("v:%d\n", v);
    res = inf;
    for(int i = 0; i < (int)adj[v].size(); i++){
        int d = adj[v][i].first;
        int w = adj[v][i].second;
        // printf("%d -> %d : %d\n", i,d,w);
        if(visSet >> d & 1) continue;
        res = min(res, w + rec(visSet, d));
    }
    return res;
}

int main(){
    while(cin >> w >> h && w){
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < (1<<12); j++){
                dp[i][j] = -1;
            }
        }
        gar.clear();
        int sv = -1;
        int si = -1, sj = -1;
        for(int i = 0; i < h; i++){
            cin >> grid[i];
            // cout << grid[i] << endl;
            for(int j = 0; j < w; j++){
                if(grid[i][j] == 'o'){
                    sv = gar.size();
                    si = i, sj = j;
                    gar.push_back(make_pair(i,j));
                }
                if(grid[i][j] == '*'){
                    gar.push_back(make_pair(i,j));
                }
            }
        }
        assert(si != -1 && sj != -1);
        n = gar.size();
        for(int i = 0; i < h*w; i++){
            for(int j = 0; j < h*w; j++){
                g[i][j] = inf;
            }
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(grid[i][j] != 'x'){
                    if(i+1 != h && grid[i+1][j] != 'x'){
                        int u = getId(i,j);
                        int v = getId(i+1,j);
                        g[u][v] = g[v][u] = 1;
                    }
                    if(j+1 != w && grid[i][j+1] != 'x'){
                        int u = getId(i,j);
                        int v = getId(i,j+1);
                        g[u][v] = g[v][u] = 1;
                    }
                }
            }
        }
        for(int k = 0; k < h*w; k++){
            for(int i = 0; i < h*w; i++){
                for(int j = 0; j < h*w; j++){
                    g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
                }
            }
        }
        // for(int i = 0; i < h*w; i++){
        //     for(int j = 0; j < h*w; j++){
        //         printf("%d ", g[i][j]);
        //     }
        //     puts("");
        // }
        
        adj.resize(n);
        for(int i = 0; i < n; i++) adj[i].clear();
        for(int i = 0; i < n; i++){
            int u = getId(gar[i].first, gar[i].second);
            for(int j = i+1; j < n; j++){
                int v = getId(gar[j].first, gar[j].second);
                int d = g[u][v];
                // printf("%d -> %d , %d\n", i,j,d);
                adj[i].push_back(make_pair(j,d));
                adj[j].push_back(make_pair(i,d));
            }
        }
        // printf("sv : %d\n", sv);
        int ans = rec(0,sv);
        if(ans == inf) ans = -1;
        cout << ans << endl;
    }
}

Measured memory_bytes: 2056