# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	while (true)
	{
		int x, y;
		int a[22][22];
		pii start; 
		vector<pii> goals;

		cin >> x >> y; if (!x)break;
		memset(a, -1, sizeof a);
		
		FORI(i, 1, y + 1)
		{
			FORI(j, 1, x + 1)
			{
				a[i][j] = 0;
				char c; cin >> c;
				if (c == 'o')start = pii(i, j);
				if (c == 'x')a[i][j] = -1;
				if (c == '*') { a[i][j] = 1; goals.emplace_back(i, j); }
			}
		}
		goals.push_back(start);

		auto calc_cost=[&a](pii start)->vector<vi> 
		{
			vi line(22, INF);
			vector<vi> ans(22, line);
			ans[start.first][start.second] = 0;
			priority_queue< piii, vector<piii>, greater<piii> >que;
			que.push(piii(0, start));
			while (!que.empty())
			{
				piii now = que.top(); que.pop();
				FOR(i, 4)
				{
					pii p=now.second;
					p.first += dy[i]; p.second += dx[i];
					if (ans[p.first][p.second] > now.first + 1 && a[p.first][p.second] != -1)
					{
						piii next(now.first+1,p);
						ans[p.first][p.second] = next.first;
						que.push(next);
					}
				}
			}
			return ans;
		};
		vector<vi> costs;
		bool ok = true;

		FOR(i, goals.size())
		{
			vector<vi> map=calc_cost(goals[i]);
			vi f;
			FOR(j, goals.size())
			{
				int cost = map[goals[j].first][goals[j].second];
				if (cost >= INF)ok = false;
				f.push_back(cost);
			}
			costs.push_back(f);
		}
		if (!ok) { cout << "-1" << endl; continue; }
		typedef pair< int, pair<int, vi> > P;
		P s(0, pair<int, vi>(goals.size() - 1, {(int)goals.size()-1}));
		priority_queue< P, vector<P>, greater<P> > que;
		que.push(s);
		
		while (!que.empty())
		{
			P now = que.top(); que.pop();
			if (now.second.second.size() == goals.size())
			{
				cout << now.first << endl;
				break;
			}
			FOR(i, costs[now.second.first].size())
			{
				if (!count(ALL(now.second.second), i))
				{
					P next = now;
					next.first += costs[now.second.first][i];
					next.second.first = i;
					next.second.second.push_back(i);
					que.push(next);
				}
			}
		}
	}
}

Measured memory_bytes: 11360