#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1000000000;

int w, h;
char c[20][25];

int x[11], y[11];
int dCounter;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int minlength[20][20];
bool used[20][20];

void bfs(P s) {
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) minlength[i][j] = INF, used[i][j] = false;
  minlength[s.second][s.first] = 0;
  queue<P> que;
  que.push(s);
  while (!que.empty()) {
    P p = que.front(); que.pop();
    int px = p.first, py = p.second;
    if (used[py][px]) continue;
    used[py][px] = true;
    for (int i = 0; i < 4; i++) {
      int newy = py + dy[i], newx = px + dx[i];
      if (newy < 0 || newy >= h || newx < 0 || newx >= w) continue;
      if (c[py + dy[i]][px + dx[i]] != 'x' && !used[newy][newx]) {
        minlength[py + dy[i]][px + dx[i]] = minlength[py][px] + 1;
        que.push(P(px + dx[i], py + dy[i]));
      }
    }
  }
}

int cost[11][11];
int bitdp[1<<12][11];

int main() {
  while (1) {
    scanf("%d%d", &w, &h);
    if (w == 0) break;
    for (int i = 0; i < h; i++) scanf("%s", c[i]);
    dCounter = 1;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (c[i][j] == '*') x[dCounter] = j, y[dCounter++] = i;
        if (c[i][j] == 'o') x[0] = j, y[0] = i;
      }
    }
    bool flag = false;
    for (int i = 0; i < dCounter; i++) {
      bfs(P(x[i], y[i]));
      for (int j = 0; j < dCounter; j++) {
        cost[i][j] = minlength[y[j]][x[j]];
        if (cost[i][j] == INF) i = j = dCounter, flag = true;
      }
    }
    if (flag) {
      printf("-1\n");
      continue;
    }
    int maxbit = (1 << dCounter) - 1 - (1 << 0);
    for (int i = 0; i < maxbit; i++)
      for (int j = 0; j < dCounter; j++) bitdp[i][j] = INF;
    bitdp[maxbit][0] = 0;
    for (int s = maxbit; s > 0; s--) {
      for (int from = 0; from < dCounter; from++) {
        int frombit = 1 << from;
        if (s & frombit) continue;
        if (bitdp[s][from] == INF) continue;
        for (int to = 0; to < dCounter; to++) {
          int tobit = 1 << to;
          if ((s & tobit) == 0) continue;
          bitdp[s - tobit][to] = min(bitdp[s - tobit][to], bitdp[s][from] + cost[from][to]);
        }
      }
    }
    int ans = INF;
    for (int i = 0; i < dCounter; i++) ans = min(ans, bitdp[0][i]);
    printf("%d\n", ans);
  }
}

