#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll d[21][21][21][21];

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

bool isOutOfRange(int x, int y, int h, int w) {
	return x < 0 || x >= w || y <0 || y >=h;
}

ll dp[11][(1<<11)];

int main(){
	int w, h;
	while(cin >> w >> h && w && h) {
		vector<string> s(h);
		rep(i, h) cin >> s[i];
		rep(i, h) rep(j, w) rep(k, h) rep(l, w) d[i][j][k][l] = ((i == k && j == l)? 0LL : (ll)1e18);
		int _sx, _sy, n = 0;
		vi X, Y;
		rep(y, h) rep(x, w) {
			if(s[y][x] == '*') {
				n++;
				X.pb(x);
				Y.pb(y);
				//continue;
			}
			else if(s[y][x] == 'x') continue;
			else if(s[y][x] == 'o') _sx = x, _sy = y;
			rep(i, 4) {
				int nx = x + dx[i], ny = y + dy[i];
				if(isOutOfRange(nx, ny, h, w) || s[ny][nx] == 'x') continue;
				d[y][x][ny][nx] = 1LL;
			}
		}
		rep(ky, h) rep(kx, w) {
			rep(sy, h) rep(sx, w) {
				rep(gy, h) rep(gx, w) {
					d[sy][sx][gy][gx] = min(d[sy][sx][gy][gx], d[sy][sx][ky][kx] + d[ky][kx][gy][gx]);
				}
			}
		}
		rep(i, n) rep(j, (1<<n)) dp[i][j] = 1e18;
		rep(i, n) dp[i][(1<<i)] = d[_sy][_sx][Y[i]][X[i]];//, cout<<" i : "<<i<<" "<<d[_sy][_sx][Y[i]][X[i]];
		REP(mask, 1, (1<<n)) {
			rep(i, n) {
				if((mask & (1 << i)) == 0) continue;
				rep(j, n) {
					if((mask & (1 << j))) continue;
					int nxt = mask | (1 << j);
					dp[j][nxt] = min(dp[j][nxt], dp[i][mask] + d[Y[i]][X[i]][Y[j]][X[j]]);
				}
			}
		}
		ll ans = 1e18;
		int gl = (1<< n) -1;
		rep(i, n) {
			ans = min(ans, dp[i][gl]);
		}
		cout<<(ans==1e18?-1:ans)<<endl;
		// cout<<_sx<<" "<<_sy<<endl;
		// rep(i, n) cout << " "<<X[i]<<" "<<Y[i]<<" "<<d[_sy][_sx][Y[i]][X[i]]<<endl;
		// rep(sy, h) rep(sx, w) {
		// 	rep(gy, h) rep(gx, w) {
		// 		cout<<" ("<<sx<<", "<<sy<<") -> ("<<gx<<", "<<gy<<") "<<d[sy][sx][gy][gx]<<endl;
		// 	}
		// }
	}
}