#include<stdio.h>
#include<string.h>
#define INF (1<<29)
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
int w,h;
char map[20][20];
struct P{
	int y,x;
};
int bfs(struct P s,struct P e){
	struct P a,b,que[400];
	int head=0,tail=0,i;
	int step[20][20];
	a=s;
	memset(step,-1,sizeof(step));	
	step[s.y][s.x]=0;
	que[tail++]=a;
	while(head < tail){
		a=que[head++];
		for(i=0;i<4;i++){
			b.y=a.y+dy[i];
			b.x=a.x+dx[i];
			if(b.y<0||h<=b.y||b.x<0||w<=b.x||step[b.y][b.x]!=-1||map[b.y][b.x]=='x')continue;
			if(b.y==e.y && b.x==e.x)return step[a.y][a.x]+1;
			step[b.y][b.x] = step[a.y][a.x]+1;
			que[tail++] = b;
		}
	}
	return -1;
}
int used[11];
int dist[11][11];
int n;
int search(int i,int depth){
	int j;
	int t,min=INF;
	if(depth==n){return 0;}
	for(j=1;j<n;j++){
		if(used[j])continue;
		used[j]=1;
		t = dist[i][j]+search(j,depth+1);
		used[j]=0;
		if(t<min)min=t;
	}
	return min;
}
int main(){
	int i,j;
	struct P yogore[11];
	while(scanf("%d%d",&w,&h)==2&&(w|h)){
		int ans=-1;
		n=1;
		scanf("\n");
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf("%c",&map[i][j]);
				if(map[i][j]=='*'){
					yogore[n].y=i;
					yogore[n].x=j;
					n++;
				}
				if(map[i][j]=='o'){
					yogore[0].y=i;
					yogore[0].x=j;
				}
			}
			scanf("\n");
		}
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				int d=bfs(yogore[i],yogore[j]);
				dist[i][j]=dist[j][i]=d;
				if(d==-1)goto END;
			}
		}
		memset(used,0,sizeof(used));
		ans=search(0,1);
		END:
		printf("%d\n",ans);
	}
}