#include <bits/stdc++.h>

class Solve {
private:

public:
	bool is_last_query_{};
	Solve()
	{
		using vi = std::vector<int>;
		using vvi = std::vector<vi>;
		using vvvi = std::vector<vvi>;
		int W, H;
		scanf("%d%d", &W, &H);
		if (W == 0)
		{
			is_last_query_ = true;
			return;
		}
		vvi room(H + 2, vi(W + 2, -1));
		int begin[2]{};
		std::map<std::pair<int, int>, int> dirt;
		for (int i{1}; i <= H; i++)
			for (int j{1}; j <= W; j++)
			{
				char tmp;
				scanf(" %c", &tmp);
				if (tmp == '.') room[i][j] = 0;
				else if (tmp == '*')
				{
					room[i][j] = 1;
					int tmp{(int)dirt.size()};
					dirt[{i, j}] = tmp;
				}
				else if (tmp == 'o')
				{
					room[i][j] = 0;
					begin[0] = i;
					begin[1] = j;
				}
			}
		vvvi distance(H + 2, vvi(W + 2, vi(1 << dirt.size(), INT_MAX)));
		using i3 = std::array<int, 3>;
		std::queue<i3> bfs;
		bfs.push({begin[0], begin[1], 0});
		distance[begin[0]][begin[1]][0] = 0;
		int goal{-1};
		int dir[4][2]{{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
		while (!bfs.empty())
		{
			auto now{bfs.front()};
			bfs.pop();
			if (now[2] == ((1 << dirt.size()) - 1))
			{
				goal = distance[now[0]][now[1]][now[2]];
				break;
			}
			for (int i{}; i < 4; i++)
			{
				i3 next;
				next[0] = now[0] + dir[i][0];
				next[1] = now[1] + dir[i][1];
				if (room[next[0]][next[1]] == -1) continue;
				next[2] = now[2];
				if (room[next[0]][next[1]] == 1)
					next[2] |= 1 << dirt[{next[0], next[1]}];
				if (distance[next[0]][next[1]][next[2]] != INT_MAX) continue;
				distance[next[0]][next[1]][next[2]] = distance[now[0]][now[1]][now[2]] + 1;
				bfs.push(next);
			}
		}
		
		printf("%d\n", goal);
		return;
	}
};

int main()
{
	while (!Solve().is_last_query_);
	return 0;
}
