#include<bits/stdc++.h>
using namespace std;

int hyou[410][410];
int room[410];
int used[11];
int D[11];
int cnt, ans,N;

void init() {
	for(int i = 0; i < 410; i++) {
		for(int j = 0; j < 410; j++) {
			hyou[i][j] = 100000;
		}
		room[i] = 100000;
	}
	cnt = 0;
	ans = 3200000;
	for(int i = 0; i < 11; i++) {
		used[i] = false;
		D[i] = false;
	}
}

void dfs(int p) {
	bool f = false;
	for(int i = 0; i < N; i++) {
		if(used[i] == false) {
			f = true;
			used[i] = true;
			cnt += hyou[p][D[i]];
			dfs(D[i]);
			cnt -= hyou[p][D[i]];
			used[i] = false;
		}
	}
	if (!f) {
		ans = min(cnt, ans);
	}
	return;
}


int main() {
	int h,w;
	while(cin >> w >> h, h | w) {
		int p = 0;
		char c;
		init();
		int s;
		for(int i = 0; i < h * w; i++) {
			cin >> c;
			if (c == '.') room[i] = 1;
			else if (c == 'x') room[i] = 100000;
			else if (c == '*') {
				room[i] = 1;
				D[p] = i;
				p++;
			}
			if (c == 'o') {
				room[i] = 1;
				s = i;
			}
		}
		N = p;
		for(int i = 0; i < h*w;i++) {
			if(i % w == 0) {
				hyou[i][i + 1] = room[i + 1];
			}
			else if (i % w == w - 1) {
				hyou[i][i - 1] = room[i - 1];
			}
			else {
				hyou[i][i - 1] = room[i - 1];
				hyou[i][i + 1] = room[i + 1];
			}
			if(i + w < h * w){
				hyou[i][i + w] = room[i + w];
			}
			if (i - w >= 0) {
				hyou[i][i - w] = room[i - w];
			}
		}
		for (int k = 0; k < h * w; k ++) {
			for(int i = 0; i < h*w; i++) {
				for(int j = 0; j < h * w; j++) {
					hyou[i][j] = min(hyou[i][k] + hyou[k][j],hyou[i][j]) ;
				}
			}
		}
		dfs(s);
		if (ans > 90000) {
			cout << -1 << endl;
		} else {
		cout << ans << endl;
		}
	}
}



