CSES - KILO 2015 5/5 - Mission
  • Time limit: 1.00 s
  • Memory limit: 128 MB

You are once again in a labyrinth. Your mission is to collect all coins and finally move to the exit cell. What is the minimum number of steps needed for this?

Each cell in the labyrinth is one of following:

  • #: wall
  • .: floor
  • A: starting cell
  • B: exit cell
  • *: coin

At each step, you can move one cell left, right, up or down.

Input

The first input line contains three integers nn, mm and kk: the height and the width of the labyrinth and the number of coins.

After this, the input describes the labyrinth. There are nn lines, each containing mm characters.

Output

Output the minimum number of steps needed for collecting the coins and finally moving to the exit cell.

You can assume that it is always possible to complete the mission.

Constraints

  • 1n,m1001 \le n, m \le 100
  • 0k80 \le k \le 8

Example

Input:

3 6 3
.AB#.*
.....#
*..#.*

Output:

19