{$APPTYPE CONSOLE}

var
  f: TextFile;
  p: array [1..25, 1..25, 1..25, 1..25] of Integer;
  a: array [0..26, 0..26] of Char;
  q_begin, q_end, dd, xd, yd: Integer;
  q: array [1..500000] of record xp, yp, xc, yc: Byte; d: Integer; end;
const
  dx: array [1..4] of Integer = (0, 1, 0, -1);
  dy: array [1..4] of Integer = (-1, 0, 1, 0);

procedure AddQ(nxp, nyp, nxc, nyc, nd: Integer);
begin
  with q[q_end] do begin
    if p[nxp, nyp, nxc, nyc] >= 0 then exit;
    if (nxc = xd) and (nyc = yd) then nd := 0;
    xp := nxp; yp := nyp; xc := nxc; yc := nyc; d := nd; dd := nd;
    p[xp, yp, xc, yc] := d;
  end;
  Inc(q_end);
  if q_end > High(q) then q_end := Low(q);
  if q_end = q_begin then begin Writeln('q!'); Halt(1); end;
end;

var
  i, j, N, nxp, nyp: Integer;
  s: String;
begin
  FillChar(a, SizeOf(a), '#');
  FillChar(p, SizeOf(p), $FF);
  Readln(N); xd := 0; yd := 0;
  for i := 1 to N do begin
    Readln(s);
    for j := 1 to N do begin
      a[i, j] := s[j];
      if s[j] = '*' then begin xd := i; yd := j; end;
    end;
  end;
  q_begin := Low(q);
  q_end := q_begin;
  dd := 0;
  for i := 1 to 4 do begin
    if a[xd + dx[i], yd + dy[i]] = '.' then 
      AddQ(xd + dx[i], yd + dy[i], xd, yd, 0);
  end;
  while q_begin <> q_end do begin
    with q[q_begin] do begin
      //Writeln(yp, ' ', xp, ' ', yc, ' ', xc, ' ', d);
      for i := 1 to 4 do begin
        nxp := xp - dx[i]; nyp := yp - dy[i];
        if (a[nxp, nyp] <> '#') and ((nxp <> xc) or (nyp <> yc)) then
          AddQ(nxp, nyp, xc, yc, d + 1);
      end;
      nxp := xp + xp - xc; nyp := yp + yp - yc;
      if (Abs(xp - xc) + Abs(yp - yc) = 1) and (a[nxp, nyp] <> '#') then
        AddQ(nxp, nyp, xp, yp, d + 1);
    end;
    Inc(q_begin);
    if q_begin > High(q) then q_begin := Low(q);
  end;
  Writeln(dd);
end.
