#include <iostream>
#include <string>
#include <vector>

using namespace std;

int w, h;
string f[20];

struct Node {
  int x, y;
};

vector<Node> nodes;
int dm[10][10]; // distance matrix

bool done[10];
int ans;

bool create_distance_matrix() {
  int cf[21][21]; // copied field
  for (int i=0; i<nodes.size(); i++) {
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        if (f[y][x] == 'x') {
          cf[y][x] = -2; // obstacle
        } else {
          cf[y][x] = -1; // tile
        }
      }
    }

    cf[nodes[i].y][nodes[i].x] = 0;
    bool changed = true;
    for (int current=0; changed; current++) {
      changed = false;
      for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
          if (cf[y][x] == current) {
            if (x > 0   && cf[y][x-1] == -1) { cf[y][x-1] = current + 1; }
            if (x < w-1 && cf[y][x+1] == -1) { cf[y][x+1] = current + 1; }
            if (y > 0   && cf[y-1][x] == -1) { cf[y-1][x] = current + 1; }
            if (y < h-1 && cf[y+1][x] == -1) { cf[y+1][x] = current + 1; }
            changed = true;
          }
        }
      }
    }

    for (int j=0; j<nodes.size(); j++) {
      int distance = cf[nodes[j].y][nodes[j].x];
      if (distance < 0) { return false; }
      dm[i][j] = distance;
    }
  }

  return true;
}

void rec(int n, int idx, int sum) {
  if (sum >= ans) { return; }
  if (n == nodes.size()) {
    if (sum < ans) { ans = sum; }
    return;
  }

  for (int i=0; i<nodes.size(); i++) {
    if (done[i]) { continue; }
    done[i] = true;
    rec(n+1, i, sum + dm[idx][i]);
    done[i] = false;
  }
}

int main() {
  while (cin >> w >> h, (w || h)) {
    for (int y=0; y<h; y++) {
      cin >> f[y];
    }

    // initialization
    nodes.clear();
    int start = -1;
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        if (f[y][x] == '*' || f[y][x] == 'o') {
          Node n = {x, y};
          nodes.push_back(n);
        }
        if (f[y][x] == 'o') {
          start = nodes.size() - 1;
        }
      }
    }

    // create distance matrix
    if (!create_distance_matrix()) {
      cout << -1 << endl;
      continue;
    }

    // solve TSP
    memset(done, false, sizeof(done));
    done[start] = true;
    ans = INT_MAX;
    rec(1, start, 0);
    cout << ans << endl;
  }

  return 0;
}
