#include <stdio.h>
#include <string.h>
#include <queue>
#include <utility>
#define INF 0x3FFFFFFF

using namespace std;


int main(void){
	int n, h, w, i, j, k, dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0}, s[11][20][20], d[11][11], a, b, dp[11][1 << 10], min;
	pair<int,int> l[11];
	queue<pair<int,int> > que;
	char field[20][21];
	while(1){
		scanf("%d%d%*c",&w,&h);
		if(w == 0 && h == 0) break;
		n = 1;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				field[i][j] = getchar();
				if(field[i][j] == '*') l[n].first = j,l[n++].second = i, field[i][j] = '.';
				else if(field[i][j] == 'o') l[0].first = j, l[0].second = i, field[i][j] = '.';
			}
			getchar();
		}
		memset(s,-1,sizeof(s));
		for(i = 0;i < n;i++){
			que.push(l[i]);
			s[i][que.front().second][que.front().first] = 0;
			while(que.size()){
				a = que.front().first, b = que.front().second;
				for(j = 0;j < 4;j++){
					if(a + dx[j] >= 0 && a + dx[j] < w && b + dy[j] >= 0 && b + dy[j] < h && field[b + dy[j]][a + dx[j]] == '.' && s[i][b + dy[j]][a + dx[j]] == -1){
						que.push(pair<int,int>(a + dx[j],b + dy[j]));
						s[i][b + dy[j]][a + dx[j]] = s[i][b][a] + 1;
					}
				}
				que.pop();
			}
		}
		for(i = 0;i < n;i++){
			for(j = 1;j < n;j++){
				d[i][j] = s[i][l[j].second][l[j].first];
				if(i != 0){
					d[j][i] = s[i][l[j].second][l[j].first];
				}
			}
		}
		for(i = 0;i < n;i++){
			for(j = 1;j < n;j++) if(d[i][j] == -1) break;
			if(j != n) break;
		}
		if(i != n){
			printf("-1\n");
			continue;
		}
		for(i = 0;i < 1 << (n - 1);i++)
			for(j = 0;j < n;j++) dp[j][i] = INF;
		dp[0][0] = 0;
		for(i = 0;i < 1 << (n - 1);i++){
			for(j = 0;j < n;j++){
				for(k = 1;k < n;k++){
					if(~i & (1 << (k - 1)) && dp[k][i | (1 << (k - 1))] > dp[j][i] + d[j][k])
						dp[k][i | (1 << (k - 1))] = dp[j][i] + d[j][k];
				}
			}
		}
		min = INF;
		for(i = 0;i < n;i++)
			if(min > dp[i][(1 << (n - 1)) - 1]) min = dp[i][(1 << (n - 1)) - 1];
		printf("%d\n",min >= INF - 0x2000000 ? -1 : min);
	}
	return 0;
}