#include <iostream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)
static const int dx[] = {1,-1,0,0} , dy[]={0,0,-1,1};
char data[30][30];
struct P{
	int x,y;
	P(int a,int b){x=a,y=b;}
	bool operator ==(const P& a){ return x == a.x && y == a.y; }
};

int bfs(P s,P g){
	// mèm[hú» , ¢KâÈçÎ-1A»¤ÅÈ¯êÎs©çÌÅZ£
	int done[30][30];
	rep(i,30)rep(j,30)done[i][j] = -1;
	
	queue<P>Q;
	Q.push(s);
	done[s.y][s.x] = 0;
	
	while(Q.size()){
		P q = Q.front(); Q.pop();
		
		if(q == g) return done[g.y][g.x];
		
		rep(i,4){
			P t = P(q.x+dx[i],q.y+dy[i]);
			if(data[t.y][t.x] == 'x' || ~done[t.y][t.x]){
				continue;
			}else{
				done[t.y][t.x] = done[q.y][q.x]+1;
				Q.push(t);
			}
		}
	}
	return INF;
}
int main(){
	int W,H;
	while(cin >> W >> H , W){
		// }bvú»
		rep(i,30)rep(j,30)data[i][j] = 'x';
		
		//@üÍ
		rep(i,H)rep(j,W)
			cin >> data[i+1][j+1];
		
		// {bgEê^CÌÊuEÂæ¾
		P s(0,0);
		vector<P> pos;
		rep(i,30)rep(j,30)
			if(data[i][j] == '*') pos.push_back(P(j,i));
			else if(data[i][j] == 'o')s = P(j,i);
		int n = pos.size();

		// eê^C¯mÌÅZoHðvZµÄ¨­B
		int dist[10][10] = {0};
		rep(i,n)rep(j,n)dist[i][j] = bfs(pos[i],pos[j]);

		// ñZ[X}ú»
		int dp[1<<10][10];
		rep(i,1<<10)rep(j,10)dp[i][j] = INF;
		
		// ñZ[X}
		rep(i,n) dp[1<<i][i] = bfs(s,pos[i]);
		rep(i,1<<n)rep(j,n)rep(k,n)
			dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+dist[j][k]);
		
		// oÍ
		int ans = INF;
		rep(i,n)ans = min(ans,dp[(1<<n)-1][i]);
		cout << (ans<INF?ans:-1) << endl;
	}
}