#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;

int save[20][20],vis[25][25],n,m,dust,ct,lp,stx,sty,sum,minn;
int mov[4][2]= {1,0,0,-1,-1,0,0,1};
char plate[25][25];
int visp[20];

struct status
{
    int cnt;
    int x,y;
    status(int a,int b,int c)
    {
        x = a, y = b, cnt = c;
    }
};
struct point
{
    int x,y;
}p[20];

queue<struct status> q;

void maek()
{
    while(!q.empty())
    {
        if(plate[q.front().x][q.front().y]=='*')
            save[0][ct+1] = q.front().cnt, p[ct+1].x = q.front().x, p[ct+1].y = q.front().y, ct++;

        for(int i=0; i<4; i++)
        {
            int tx = q.front().x + mov[i][0], ty = q.front().y + mov[i][1];
            if(tx >= 0 && tx < m && ty >=0 && ty < n && plate[tx][ty] != 'x' && !vis[tx][ty])
            {
                struct status temp(tx, ty, q.front().cnt + 1);
                vis[tx][ty] = 1;
                q.push(temp);
            }
        }
        q.pop();
    }
}

void play(int x, int y, int ord)
{
    int ctt = 0;
    vis[q.front().x][q.front().y] = 1;
    while(ctt != ct)
    {
        if(plate[q.front().x][q.front().y]=='*')
        {
            int r;
            for(r=1; r<=ct; r++)
                if(p[r].x == q.front().x && p[r].y == q.front().y) break;
            save[ord][r] = q.front().cnt, ctt++;
        }

        for(int i=0; i<4; i++)
        {
            int tx = q.front().x + mov[i][0], ty = q.front().y + mov[i][1];
            if(tx >= 0 && tx < m && ty >=0 && ty < n && plate[tx][ty] != 'x' && !vis[tx][ty])
            {
                struct status temp(tx, ty, q.front().cnt + 1);
                vis[tx][ty] = 1;
                q.push(temp);
            }
        }
        q.pop();
    }
}


void dfs(int x,int y,int ore)
{
    //printf("%d %d %d %d\n",x,y,ore,sum);

    if(x==y)
    {
        minn = minn > sum ? sum : minn;
    }

    for(int i=1; i<=ct; i++)
    {
        if(!visp[i])
        {
            if(sum + save[ore][i] > minn) continue;
            else
            {
                sum += save[ore][i];
                x++;
                visp[i] = 1;
                dfs(x,y,i);
                visp[i] = 0;
                sum -= save[ore][i];
                x--;
            }
        }
    }
}


int main()
{
    //freopen("C://1140-input.txt","r",stdin);
    //freopen("C://zout.txt","w",stdout);

    while(~scanf("%d%d",&n,&m),n+m)
    {

        memset(plate, 0, sizeof(plate));
        memset(vis,0,sizeof(vis));
        memset(save,0,sizeof(save));
        memset(visp,0,sizeof(visp));
        memset(p,0,sizeof(p));

        getchar();
        lp = 0, ct = 0;
        for(int i=0; i<m; i++)
        {
            for(int j=0; j<n; j++)
            {
                scanf("%c",&plate[i][j]);
                if(plate[i][j]=='o') stx = i, sty = j;
                if(plate[i][j]=='*') lp++;
            }
            getchar();
        }

        struct status tm(stx,sty,0);
        q.push(tm);
        maek();

        if(ct != lp) printf("-1\n");
        else
        {
            for(int i=1; i<=ct; i++)
            {
                memset(vis,0,sizeof(vis));
                struct status temp(p[i].x, p[i].y, 0);
                q.push(temp);
                play(p[i].x, p[i].y, i);
                while(!q.empty()) q.pop();
            }

           /* for(int i=0;i<=ct;i++)
            {
                for(int j=0;j<=ct;j++)
                {
                    printf("%3d ",save[i][j]);
                }
                printf("\n");
            }*/
            minn = 99999999;

            for(int i=1; i<=ct; i++)
            {
                memset(visp,0,sizeof(visp));
                sum = save[0][i],visp[i] = 1;
                dfs(1,ct,i);
            }
            printf("%d\n",minn);
        }
    }
    return 0;
}


/*

7 10
......x
*...*.x
.......
.......
....*.*
.......
.......
.o.....
**.....
..*....

7 5
.......
.o...*.
.......
.*...*.
.......

13 17
............x
..........x.x
............x
.......**....
.............
....*.......x
............x
o..........xx
...*.*......x
............x
.......x.....
............x
.....xx*.x.xx
.....x.....xx
...xxx....xxx
.*xxxx...xxxx
.xxxxxx..xxxx

15 7
*.o.*..........
.........**....
.*.............
...............
...............
...............
x.......*....*.

*/

Measured memory_bytes: 1072