Skip to main content

~/algor $ cat contests/round-6/I

I. Through the walls

Problem I ICPC rules 2000 ms 256 MB

On a map of rows and columns, . is an empty cell and # is a wall. A robot must get from the top-left cell to the bottom-right cell. In one step it moves to an adjacent (up, down, left or right) cell; before entering a cell with a wall it breaks that wall. What is the smallest number of walls the robot has to break?

A 4 × 5 map: the robot's route and the one wall broken on the way

Input

The first line contains two positive integers: and . Each of the next lines contains a string of characters (. or #).

Output

One integer — the number of broken walls.

Note


the top-left and bottom-right cells are empty

Examples

Input #1
4 5
..#..
##.#.
.#.##
.#...
Output #1
1
Input #2
3 3
.#.
###
.#.
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.