#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

const int MAX=INT_MAX/100;
int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int bfs(vs &c,pii from,pii to,int h,int w){
	queue<pii> q;
	q.push(from);
	vvi cost(h,vi(w,MAX));
	cost[from.first][from.second]=0;
	while(!q.empty()){
		pii p=q.front();q.pop();
		REP(d,4){
			int y=p.first+dy[d];
			int x=p.second+dx[d];
			if(y>=0&&x>=0&&y<h&&x<w&&c[y][x]!='x'&&cost[y][x]==MAX){
				q.push(make_pair(y,x));
				cost[y][x]=cost[p.first][p.second]+1;
			}
		}
	}
	return cost[to.first][to.second];
}

int main(){
	int w,h;
	while(cin>>w>>h,w|h){
		vs c(h);
		vector<pii> targets;
		pii start;
		REP(i,h){
			cin>>c[i];
			REP(j,w){
				if(c[i][j]=='*'){
					targets.push_back(make_pair(i,j));
				}else if(c[i][j]=='o'){
					start=make_pair(i,j);
				}
			}
		}
		targets.push_back(start);
		int sz=targets.size();
		vvi cost(sz+1,vi(sz+1));
		REP(i,sz){
			FOR(j,i+1,sz){
				cost[i][j]=bfs(c,targets[i],targets[j],h,w);
				cost[j][i]=cost[i][j];
			}
		}

		vi order(sz-1);
		REP(i,sz-1){
			order[i]=i;
		}
		int ans=MAX;
		do {
			int dist=cost[sz-1][order[0]];
			REP(i,sz-2){
				dist+=cost[order[i]][order[i+1]];
			}
			ans=min(ans,dist);
		}while(next_permutation(ALL(order)));
		cout<<(ans==MAX?-1:ans)<<endl;
	}
}