#include<iostream>
#include<list>
#include<cstring>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

int p[400][400];
int d[11][11];
int w,h,wh;
int r;
vector<int> v;

int pd(int s,int n){
    if(s == 0) return 0;
    int i,j;
    int min = 10000000;
    for(i = 0;i < v.size();i++){
        if(s & (1<<i)){
            j = pd(s-(1<<i),i);
            if(min > d[n][i]+j) min = d[n][i] + j;
        }
    }
    return min;
}

int main(){
    int i,j,k;
    int min = 10000000;
    char c;
    while(1){
        cin >> w >> h;
        if(!w) break;
        w ^= h;h ^= w;w ^= h;
        v.clear();
        wh = w*h;
        for(i = 0;i < wh;i++){
            for(j = 0;j < wh;j++){
                p[i][j] = 10000;
            }
            p[i][i] = 0;
        }
        for(i = 0;i < w;i++){
            for(j = 0;j < h;j++){
                if(i > 0){
                    p[i*h+j][(i-1)*h+j] = 1;
                    p[(i-1)*h+j][i*h+j] = 1;
                }
                if(j > 0){
                    p[i*h+j][i*h+j-1] = 1;
                    p[i*h+j-1][i*h+j] = 1;
                }
                if(i < w-1){
                    p[i*h+j][(i+1)*h+j] = 1;
                    p[(i+1)*h+j][i*h+j] = 1;
                }
                if(j < h-1){
                    p[i*h+j][i*h+j+1] = 1;
                    p[i*h+j+1][i*h+j] = 1;
                }
            }
        }
        for(i = 0;i < w;i++){
            for(j = 0;j < h;j++){
                cin >> c;
                switch(c){
                    case 'x':
                        if (i > 0) {
                            p[i * h + j][(i - 1) * h + j] = 10000;
                            p[(i - 1) * h + j][i * h + j] = 10000;
                        }
                        if (j > 0) {
                            p[i * h + j][i * h + j - 1] = 10000;
                            p[i * h + j - 1][i * h + j] = 10000;
                        }
                        if (i < w - 1) {
                            p[i * h + j][(i + 1) * h + j] = 10000;
                            p[(i + 1) * h + j][i * h + j] = 10000;
                        }
                        if (j < h - 1) {
                            p[i * h + j][i * h + j + 1] = 10000;
                            p[i * h + j + 1][i * h + j] = 10000;
                        }
                        break;
                    case 'o':
                        r = i*h+j;
                        break;
                    case '*':
                        v.push_back(i*h+j);
                        break;
                }
            }
        }
        for(k = 0;k < wh;k++){
            for(i = 0;i < wh;i++){
                for(j = 0;j < wh;j++){
                    p[i][j] = (p[i][j]>p[i][k]+p[k][j])?p[i][k]+p[k][j]:p[i][j];
                }
            }
        }
        k = 0;
        for(i = 0;i < v.size();i++){
            for(j = 0;j < v.size();j++){
                if(p[v[i]][v[j]] >= 10000){
                    k = 1;
                }
                d[i][j] = p[v[i]][v[j]];
            }
        }
        min = 10000000;
        for(i = 0;i < v.size();i++){
            if(p[r][v[i]] >= 10000){
                k = 1;
            }
            else{
                j = pd((1<<v.size())-1-(1<<i),i);
                j += p[r][v[i]];
                if(min > j) min = j;
            }
        }
        if(k){
            cout << -1 << endl;
        }
        else{
            cout << min << endl;
        }
    }
}

Measured memory_bytes: 1812