Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

MUNCH - Munching

Rob Kolstad, 2008

Bessie loves her grass and loves to hurry to the barn for her evening milking session. She has partitioned the pasture into a rectilinear grid of R (1 <= R <= 100) rows and C (1 <= C <= 100) columns and marked the squares as grass or rocky (she can't eat rocks and won't even go into those squares). Bessie starts on her map at location R_b,C_b and wishes to munch her way, square by square, to the barn at location 1,1 by the shortest route possible. She moves from one square to any one of the potentially four adjacent squares.

Below is the original map [with rocks ('*'), grass ('.'), the barn ('B'), and Bessie ('C' for cow) at row 5, col 6] and a route map with the optimal route marked with munches ('m'):

           Map               Optimal Munched Route
        1 2 3 4 5 6  <-col      1 2 3 4 5 6  <-col
      1 B . . . * .           1 B m m m * .
      2 . . * . . .           2 . . * m m m
      3 . * * . * .           3 . * * . * m
      4 . . * * * .           4 . . * * * m
      5 * . . * . C           5 * . . * . m

Bessie munched 9 squares.

Given a map, determine how many squares Bessie will eat on her shortest route to the barn (there's no grass to eat on the barn's square).

Input

  • Line 1: Two space-separated integers: R and C
  • Lines 2..R+1: Line i+1 describes row i with C characters (and no spaces) as described above

Output

  • Line 1: A single integer that is the number of squares of grass that Bessie munches on the shortest route back to the barn

Example

Input:
5 6
B...*.
..*...
.**.*.
..***.
*..*.C

Output:
9

Adicionado por:Wanderley Guimarăes
Data:2008-06-06
Tempo limite:0.100s
Tamanho do fonte:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Linguagem permitida:ADA95 DOC ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PDF PERL PHP PIKE PS PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE
Origem:USACO Open 2008 - Bronze

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.