#include <algorithm>  // max, min, sort
#include <iomanip>    // setprecision
#include <iostream>
#include <queue>
#include <set>
#include <vector>
// #include <bits/stdc++.h>

using namespace std;

const double EPS = 1e-10;

struct Node
{
    Node(int X, int Y, int C)
    {
        x = X;
        y = Y;
        cost = C;
    }

    int x, y, cost;
};

void findObs(int sobs, vector<string>& map, vector<pair<int, int> >& obs, vector<vector<int> >& costVec)
{
    int h = map.size();
    int w = map[0].length();

    queue<Node> q;  // sx, sy
    bool visited[h][w];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) visited[i][j] = false;

    q.push(Node(obs[sobs].first, obs[sobs].second, 0));

    while (q.size() > 0)
    {
        Node cur = q.front();
        int x = cur.x;
        int y = cur.y;
        int cost = cur.cost;
        q.pop();

        if (visited[y][x] || x < 0 || x >= w || y < 0 || y >= h || map[y][x] == 'x') continue;
        visited[y][x] = true;

        if (map[y][x] == '*')
        {
            for (int i = 0; i < obs.size(); i++)
            {
                if (x == obs[i].first && y == obs[i].second) costVec[sobs][i] = min(costVec[sobs][i], cost);
            }
        }

        q.push(Node(x + 1, y, cost + 1));
        q.push(Node(x - 1, y, cost + 1));
        q.push(Node(x, y + 1, cost + 1));
        q.push(Node(x, y - 1, cost + 1));
    }
}

struct DNode
{
    DNode(int i, int c, set<int>& v)
    {
        idx = i;
        cost = c;
        visited = v;
    }
    int idx;
    int cost;
    set<int> visited;
    //long long visited;
};

struct CustomCompare
{
    bool operator()(const DNode& n1, const DNode& n2)
    {
        return n1.cost > n2.cost;
    }
};

int dijkstra(vector<string>& map, vector<pair<int, int> >& obs, vector<vector<int> >& costVec)
{
    priority_queue<DNode, vector<DNode>, CustomCompare> q;
    set<int> v;
    q.push(DNode(0, 0, v));

    set<pair<int, set<int> > > checked;

    while (q.size() > 0)
    {
        DNode d = q.top();
        q.pop();

        if (d.visited.size() == obs.size() - 1) return d.cost;
        if (checked.find(make_pair(d.idx, d.visited)) != checked.end()) continue;
        checked.insert(make_pair(d.idx, d.visited));

        for (int i = 1; i < obs.size(); i++)
        {
            if (i == d.idx || d.visited.find(i) != d.visited.end() || costVec[d.idx][i] == 9999) continue;
            set<int> nv = d.visited;
            nv.insert(i);
            if (checked.find(make_pair(i, nv)) != checked.end()) continue;
            q.push(DNode(i, d.cost + costVec[d.idx][i], nv));
        }
    }

    return -1;
}

int main()
{
    // n, r　適切な変数名に置き換える
    int w, h;
    while (cin >> w >> h, w != 0 && h != 0)
    {
        // Global 変数の初期化忘れずに

        vector<string> map(h);
        vector<pair<int, int> > obs;  // (x, y)
        int sx, sy;
        for (int i = 0; i < h; i++)
        {
            cin >> map[i];
            for (int j = 0; j < w; j++)
            {
                if (map[i][j] == 'o')
                {
                    sx = j;
                    sy = i;
                }
                else if (map[i][j] == '*')
                {
                    obs.push_back(make_pair(j, i));
                }
            }
        }

        obs.insert(obs.begin(), make_pair(sx, sy));

        // for (int i = 0; i < obs.size(); i++)
        // {
        //     cout << "{" << obs[i].first << ", " << obs[i].second << "} ";
        // }
        // cout << endl;

        vector<vector<int> > cost(obs.size());
        for (int i = 0; i < obs.size(); i++)
        {
            cost[i] = vector<int>(obs.size());
            for (int j = 0; j < obs.size(); j++) cost[i][j] = 9999;
        }

        for (int i = 0; i < obs.size(); i++)
        {
            findObs(i, map, obs, cost);
        }

        // for (int i = 0; i < obs.size(); i++)
        // {
        //     for (int j = 0; j < obs.size(); j++) cout << cost[i][j] << " ";
        //     cout << endl;
        // }

        int ans = dijkstra(map, obs, cost);
        if (ans == 9999) ans = -1;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4856